gpt4 book ai didi

java - 单击部分标记内的元素

转载 作者:行者123 更新时间:2023-12-02 01:59:33 25 4
gpt4 key购买 nike

该元素位于标签内,但尝试了很多方法都无法单击它。

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@value='Login to Register']"))).click();

WebElement element = driver.findElement(By.xpath("//input[@value='Login to Register']"));
JavascriptExecutor jsEx= (JavascriptExecutor)driver;
jsEx.executeScript("arguments[0].click();", element);

这是 html:

<div id="requestRegistrationWidget">
<a id="requestLocationLogin" href="/user/login?destination=%2Fsearch%2Flocations%2Fwidget%3Fparam1%3D006046-0619_1565278200_11000000%26param2%3D3" class="use-ajax login-popup-form" data-dialog-type="modal">
<input class="btn btn-primary" style="width: 100% !important;" type="button" value="Login to Register"></input>
</a>
<!-- registerSession == 3 and registerAnyActiveSession == 1 case (2) -->
</div>

最佳答案

您可以尝试一下下面的代码吗?

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.id("requestLocationLogin"))).click();

关于java - 单击部分标记内的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57381348/

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