gpt4 book ai didi

java - 如何通过Selenium webdriver和xpath找到按钮元素

转载 作者:行者123 更新时间:2023-11-29 08:27:59 26 4
gpt4 key购买 nike

snapshot

 <button class="add-school btnEditDashboard btn btn-primary pull-right" ng-click="CreateNewSchool()" name="AddSchool" type="submit">Add School</button>

也尝试过 xpath。 (\\html/body/div[2]/div/div[2]/div/div/div[1]/div/div[2]/button)

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"tag name","selector":"AddSchool"}

最佳答案

试试这段代码:

new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='Add School' and @name='AddSchool' and @ng-click='CreateNewSchool()']"))).click();  

如果在iframe中,请将驱动程序的焦点切换到相应的iframe,然后尝试与之交互。

关于java - 如何通过Selenium webdriver和xpath找到按钮元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50813278/

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