【发布时间】:2019-02-13 18:35:25
【问题描述】:
我可以在下面使用哪个定位器?
<span class="tile-name ng-binding">Payment Partner</span>
来自 OP 的 cmets 的更新:
代码试用 1:
driver.findElementByXPath("//span[text()='Payment Partner']").click();
错误:
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible;
代码试用 2:
driver.findElementByCssSelector("Payment Partner").click();
错误:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"Payment Partner"}
代码试用 3:
WebDriverWait wait = new WebDriverWait(driver, 20);wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath ("//span[text()='Payment Partner']')")));
【问题讨论】:
-
分享您的 XPath 和 CSS 选择器
-
以文本格式或您尝试过的url和代码分享html
-
@Andersson 请检查我的新更新
-
@sers 请检查我的新更新
-
@Catia 你也应该分享你的代码尝试
标签: java selenium xpath css-selectors webdriver