gpt4 book ai didi

java - 无法单击复选框以取消选中它似乎已隐藏

转载 作者:行者123 更新时间:2023-11-29 05:00:08 25 4
gpt4 key购买 nike

复选框是默认选中的,不能点击取消选中。这是我的代码,但返回时出现错误,指出元素当前不可见,因此可能无法与之交互。 org.openqa.selenium.ElementNotVisibleException。

String checkboxXPath =("//input[contains(@type='checkbox',@name='key_IT_CONFIG.ios.restriction.functionality.enable.camera_checkboxVal')]");
WebElement elementToClick = driver.findElement(By.xpath(checkboxXPath));
elementToClick.click();

网站代码

<input type="checkbox" class="uwp_inputCheckBox" 
name="key_IT_CONFIG.ios.restriction.functionality.enable.camera_checkboxVal"
id="key_IT_CONFIG.ios.restriction.functionality.enable.camera"
value="true" dir="ltr" hierarchy="false" expand="true"
checkedval="true" uncheckedval="false"
onclick="checkboxChange('IT_CONFIG.ios.restriction.functionality.enable.camera')"
checked="checked">

完整代码

whole code http://imageshack.com/a/img661/1720/SIi6Xj.png

最佳答案

我认为您应该使用显式等待直到元素可见。请在此处检查更新代码并使用它:

String checkboxXPath =("//input[contains(@type='checkbox',@name='key_IT_CONFIG.ios.restriction.functionality.enable.camera_checkboxVal')]");

WebDriverWait wait = new WebDriverWait(driver,30);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(checkboxXPath)));

WebElement elementToClick = driver.findElement(By.xpath(checkboxXPath));
elementToClick.click();

关于java - 无法单击复选框以取消选中它似乎已隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32386623/

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