Issue
I'm basically new to automation testing, been using JAVA+SELENIUM, Eclipse.
Been trying to open the "Europe" tree with the geckodriver.exe Webdriver. Been searching for solutions, but to no avail.
This is the page, that needs to be tested. https://js.devexpress.com/Demos/WidgetsGallery/Demo/Common/NavigationOverview/Angular/Light/
My code for opening the tree.
public class Test_suite {
@Test
public void testAssertFunctions() throws InterruptedException {
System.setProperty("webdriver.firefox.driver", "C:\\selenium-3.141.59\\draiveri\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://js.devexpress.com/Demos/WidgetsGallery/Demo/Common/NavigationOverview/Angular/Light/");
Thread.sleep(10000);
WebElement fruits = driver.findElement(By.xpath("/html/body/div/demo-app/div/div[1]/dx-tree-view/div[2]/div/div/div[1]/ul/li[4]/div[2]"));
fruits.click();
}
}
It seems I can't locate the element, have tried multiple findElement.by
options, but to no help. Only solution that sort of worked was using Selenium IDE, which did the click to expand the tree, and it shows xpath=//li[4]/div[2]
, but after copying that path to eclipse, still does not find the element.
Solution
Please try this:
public class Test_suite {
@Test
public void testAssertFunctions() throws InterruptedException {
System.setProperty("webdriver.firefox.driver", "C:\\selenium-
3.141.59\\draiveri\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://js.devexpress.com/Demos/WidgetsGallery/Demo/Common/NavigationOverview/Angular/Light/");
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//iframe[@id='demoFrame']")));
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@id='demoFrame']")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Europe']"))).click();
}
}
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.