gpt4 book ai didi

java - Selenium 单击复选框 -React::before

转载 作者:行者123 更新时间:2023-12-01 21:51:46 25 4
gpt4 key购买 nike

我正在尝试单击一个复选框,以下是我尝试过的一些操作:

  1. //label[string()=('通知用户')]/i
  2. //div[@class='b-checkbox']
  3. //div[@class='b-checkbox']//标签//input[@type='checkbox']
    <div class="b-checkbox">
<label class="">
<input type="checkbox" value="on"><!-- react-text: 563 -->Notify user<!-- /react-text -->
<i class="b-custom"></i></label>
</div>
<div class="b-body b-mh-medium"><div class="b-body b-mv-small">
<fieldset class="b-form-group">
<label class="currency-input-label" for="currency-input-field">
<span class="currency-input-label" disabled="">
<span>When should we notify you that funds are low?</span>
</span>
<br>
<span class="b-prepend">$</span>
<input type="number" class="b-inline b-w-medium b-form-control" id="currency-input-field" value="" disabled="">
<span class="b-text-base currency-input-grey-text">Remaining</span>
</label>
<span class="b-help b-hide"></span>
<span class="b-error b-hide"></span>
</fieldset>
</div>
</div>

但是我得到了 element not 棘手的错误。有什么建议吗?提前致谢。

最佳答案

尝试使用操作:

WebElement element = driver.findElement(By.xpath("//div[@class='b-checkbox']//label//input[@type='checkbox']"));
Actions action = new Actions(driver);
action.moveToElement(element).click(element).build().perform();

JavascriptExecutor:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);

导入后:

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

关于java - Selenium 单击复选框 -React::before,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58759577/

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