gpt4 book ai didi

javascript - 无法使用 Protractor 单击按钮

转载 作者:行者123 更新时间:2023-11-28 03:38:47 25 4
gpt4 key购买 nike

我尝试使用 Protractor 单击按钮似乎不起作用:

这是我尝试过的:

const city = element.all(by.css('.filter-bar .filter-button-wrapper .filter-button')).get(0).click();

这是 html:

    <div class="content-wrapper list-page">
<div class="content">
<div class="section-wrapper page-full-width">
<div class="section page-centered">
<div class="filter-bar"><span class="medium-utility-label filter-by-label">Filter by:</span>
<div role="button" class="filter-button-wrapper" tabindex="0" aria-label="Filter by City: All" aria-haspopup="true" aria-expanded="false">
<div class="filter-button">City
<svg class="filter-button-caret icon icon-caret-down" width="16px" height="16px" viewBox="0 0 16 16">
<path d="M7.6741598,11.3413318 L8.03952616,11.7324251 L8.40489252,11.3413318 L14.8653664,4.42595055 L14.1346336,3.74328687 L7.6741598,10.6586682 L8.40489252,10.6586682 L1.86536636,3.65866816 L1.13463364,4.34133184 L7.6741598,11.3413318 Z M7.6741598,11.3413318" fill="#979797"></path>
</svg>
</div>
<div class="filter-popup">
<ul>
<li>
<a class="category-link selected" href="?" rel="nofollow">
<svg class="selected-filter-checkmark icon icon-checkmark" width="16px" height="16px" viewBox="0 0 16 16">
<path d="M6.2,14.4L0,8.2l2.5-2.5l3.5,3.5c0.1,0.1,0.2,0.1,0.2,0L13.5,2L16,4.5L6.2,14.4z"></path>
</svg>All</a>
</li>
<li><a class="category-link" href="?location=Chicago%2C%20Illinois" rel="nofollow">Chicago, Illinois</a>
</li>
<li><a class="category-link" href="?location=Edmonton%2C%20Alberta%2C%20Canada" rel="nofollow">Edmonton, Alberta, Canada</a>
</li>

单击按钮应打开下拉列表。

最佳答案

不知道为什么在没有这样的元素时要尝试单击具有三个类的元素,以及为什么在只有一个按钮时要使用 element.all...但我可以假设您需要最后一个 div 元素(就在图标之前)。请尝试这个:

element(by.cssContainingText(".filter-button", "City")

关于javascript - 无法使用 Protractor 单击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57469994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com