我正在使用Selenium Web驱动程序在google chrome浏览器中自动化Web模块。我已经创建了一个Web元素的相对XPath,但我想单击它,但不幸的是,它无法正常工作,并且给我一个例外,该XPath不在网页上。动态XPath不能正常工作,因为我首先捕获了这一点,这就是为什么我创建了相对XPath的原因。
硒代码:
//Dashboard:
WebElement ele = driver.findElement(By.xpath("//*[@id=\"sidebar\"]/section/ul/li[1]/a"));
Actions action = new Actions(driver);
action.moveToElement(ele).perform(); // Mover Hover
WebElement ele2 = driver.findElement(By.xpath("//*[@id=\"sidebar\"]/section/ul/li[1]/ul/li[1]/a"));
ele2.click(); // Click onto Weather
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
WebElement ele4 = driver.findElement(By.xpath("//*[contains(@id, 'pvExplorationHost')]//li[1]/div"));
ele4.click();
网页上的HTML代码:
<div class="textLabel" ng-click="disableClick || makeEditable()" title="Waffle Charts - All Variables">Waffle Charts - All Variables</div>
请告诉我,我对Selenium Web-Driver感到陌生,在这里我被困住了。
慕森卡
慕尼黑8549860
相关分类