Home > Back-end >  Unable to locate element for simple node
Unable to locate element for simple node

Time:12-06

Using latest Selenium -server-4.7.0 jar and latest jdk , selenium is frequently giving no such element found error.

URL

Sample Code:

public static void main(String[] args) throws InterruptedException 
    {
        System.setProperty(
            "webdriver.chrome.driver",
            "C:\\Users\\USER\\Downloads\\chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get("https://msqabaseappsa.z13.web.core.windows.net/#/");
        WebElement b = driver.findElement(By.xpath("//button/span[text()='Microsoft Sign In']"));
        b.click();
        System.out.print("Click Succeess");
        driver.close();
    }

Problem : Need to click on "Microsoft Sign In"

CodePudding user response:

Add some wait:

driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
driver.get("https://msqabaseappsa.z13.web.core.windows.net/#/");
WebElement b = driver.findElement(By.xpath(".//*[@class='btn btn-success btn-block']"));
b.click();
  • Related