我想根据截图在添加新教育字段时在linkedin配置文件中找到(加号)的Xpath
driver.findElement(By.xpath(".//*[contains(@aria-label,'Add new education')]")).click();
但是发现一条错误消息:
无法找到元素
尝试使用以下xpath。
driver.findElement(By.xpath(".//li-icon[@aria-label ='Add new education']")).click();
注意:如果您仍然无法找到该元素,那么即使您在网页上加载该元素之前,您可能仍在尝试访问该元素。在这种情况下,你需要使用
//30 is the wait time in seconds.
WebDriverWait wait = new WebDriverWait(driver,30);
//This will wait for 30 seconds to locate the element before throwing an Exception.
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//li-icon[@aria-label ='Add new education']")));
让我知道这个是否奏效。
欢迎来到SO。这是确定教育中的+
的定位器。
使用CSS a[class$='add-education ember-view']
driver.findElement(By.cssSelector("a[class$='add-education ember-view']")).click();
xpath //a[contains(@class,'add-education ember-view')]
driver.findElement(By.xpath("//a[contains(@class,'add-education ember-view')]")).click();