![](/img/trans.png)
[英]xpath query for editing a single sub-element with the same name and value that is contained in other elements
[英]Error in finding xpath for a sub-element in HTML
我正在使用下面的代碼
Actions action=new Actions(driver);
action.moveToElement(facultyOfCivil).build().perform();
WebElement oceanManagement=driver.findElement(By.xpath("//a[@href='https://www.annauniv.edu/iom/home.php']"));
action.moveToElement(oceanManagement).build().perform();
oceanManagement.click();
將鼠標懸停在元素上后,我無法為子元素找到 xpath,因為子元素未顯示在 HTML 中
使用JavaScriptExecutor
單擊元素。 試試這個,
WebDriverWait webDriverWait = new WebDriverWait(driver, 10);
Actions actions = new Actions(webDriver);
actions.moveToElement(facultyOfCivil).build().perform();
WebElement oceanManagement = webDriverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id="menuItemHilite32"]")));
((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView();", oceanManagement);
((JavascriptExecutor) webDriver).executeScript("arguments[0].click();", oceanManagement);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.