Selenium Webdriver: Element Not Visible Exception

68,626

Solution 1

You have two buttons with given xpath on this page, first is not visible, thats why you are getting ElementNotVisibleException

One is under <div class="loginPopup">

Second (the one you need) is under <div class="page">

So change your xpath to look like this, and it will fix your problem:

By.xpath("//div[@class='page']//div[@id='_loginButton']")

Solution 2

There are even 3 elements with id="_loginButton" on the page, and only one is visible - the one located inside the login form, you can get it by a CSS selector:

By.cssSelector("form#_loginForm div#_loginButton")

Solution 3

There are 3 occurrences of id="_loginButton".

Used the id="_loginButton" under class="signIn" by cssSelector to get the exact button in the page.

By.cssSelector("div.signIn div#_loginButton")
Share:
68,626
Nik_stack
Author by

Nik_stack

Updated on July 05, 2022

Comments

  • Nik_stack
    Nik_stack almost 2 years

    Here is my code to click a simple login button on this Website

    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.By;    
    import org.openqa.selenium.WebDriver;    
    import org.openqa.selenium.firefox.FirefoxDriver;    
    
    public class Reports {
    
        public static void main(String[] args) {
    
            WebDriver driver = new FirefoxDriver();
            driver.get("https://platform.drawbrid.ge");
            driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
            driver.findElement(By.xpath(".//*[@id='_loginButton']")).click();
    
        }
    }
    

    I am getting following error:

    Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 2.05 seconds