gpt4 book ai didi

javascript - 在下拉列表中选择选项使用 java 在 selenium 中实现 css

转载 作者:行者123 更新时间:2023-11-28 03:19:30 26 4
gpt4 key购买 nike

我无法在下拉列表中选择选项,使用 java 在 selenium 中实现 css。我正在尝试使用 id,但每次 id 都在变化。

driver.findElement(By.cssSelector("input.select-dropdown.active")).click();
driver.findElement(By.xpath("//ul[@id='select-options-db8c4be0-fa76-9286-bbef-80bde7193503']/li[2]/span")).click();

页面来源:

<div class="input-field">
<div class="select-wrapper validate mandatory">
<span class="caret"></span>
<input class="select-dropdown active" type="text" value="Organization Type" data-activates="select-options-465e6e55-1802-f0a6-4956-dafb1c063abc" readonly="true" tabindex="5" style="color: rgb(170, 170, 170);">
<ul id="select-options-465e6e55-1802-f0a6-4956-dafb1c063abc" class="dropdown-content select-dropdown active" style="width: 465px; position: absolute; top: 0px; left: 0px; opacity: 1; display: block;">
<li class="selected">
<span class="" data-target="">Organization Type</span>
</li>
<li class="">
<span class="" data-target="">Provider</span>
</li>
<li class="">
<span class="" data-target="">Billing Agent</span>
</li>
</ul>
<select id="orgType" class="validate mandatory initialized" tabindex="5" name="orgType">
<option value="">Organization Type</option>
<option value="Provider">Provider</option>
<option value="Billing Agent">Billing Agent</option>
</select>
</div>
</div>

最佳答案

这都是关于 xpath 创建的。你可以试试

 Xpath=//li[contains(text(),'Provider')]  or //div[@class='input-field']/div/ul/li[2]/span  or may others also

这对您有帮助 https://www.guru99.com/xpath-selenium.html

关于javascript - 在下拉列表中选择选项使用 java 在 selenium 中实现 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45283243/

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