package demoQA;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class WebTable {
static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://demoqa.com/");
driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]")).click();
WebDriverWait wait=new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfAllElements(driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/ul[1]/li[4]/span[1]"))));
//driver.findElement(By.xpath("//div[@class='left-pannel']/div/div[1]/div/ul/li[4]/*[contains(text(),'Web Tables')]")).click();
//driver.findElement(By.xpath("//span[contains(text(),'Web Tables')]")).click();
driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/ul[1]/li[4]/span[1]")).click();
}
}
Instructor
Ashish Thakur Replied on 05/08/2020
You will have to scroll down so that this element comes in the view. If element is not in view then at times you will get the same exception - org.openqa.selenium.ElementClickInterceptedException
I took similar examples in videos as well