Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The element is obscured(Server did not provide stack information) automation in edge browser with selenium

Tags:

selenium

org.openqa.selenium.WebDriverException: Element is obscured (WARNING: The server did not provide any stacktrace information). This code is working fine for chrome and firefox but not with edge browser.

     `public class Login {
            public WebDriver driver;
            By userName = By.id("ctl14_UserName");
            By password = By.id("ctl14_Password");
            By login = By.id("ctl14_LoginButton");

            public Login(WebDriver driver) {
                this.driver = driver;
            }
            // Set password in username textbox
            public void setUserName(String strUserName) {   
                driver.findElement(userName).sendKeys(strUserName); 
            }
            // Set password in password textbox
            public void setPassword(String strPassword) {
                driver.findElement(password).sendKeys(strPassword);
            }
          public void clickMyaccount(){
               driver.findElement(myAccount).click();
            }
        // Click on login button
            public void clickLogin() {
                driver.findElement(login).click();

            }
        }
        //Test class
        public class AdminLogin extends BaseForDifferentLogins {
                 Login objLoginAdmin;
                 @Test(priority=0)
                    public void login() throws InterruptedException{
                      objLoginAdmin=new Login(driver); 
                      objLoginAdmin.clickMyaccount();
                        Thread.sleep(3000);
                        objLoginAdmin.setUserName("superuser1");
                        objLoginAdmin.setPassword("superuser1");
                        Thread.sleep(3000);
                        objLoginAdmin.clickLogin();
                        Thread.sleep(3000);
                    }
        }`
like image 233
memaiya Avatar asked Apr 20 '17 06:04

memaiya


3 Answers

Instead of using webElement.click() you can try to build Actions with click and do perform. Had the same issue on Edge and that did the trick for me:

Actions actions = new Actions(webDriver); actions.click(webElement).perform();

like image 102
Amit Pe'er Avatar answered Nov 15 '22 21:11

Amit Pe'er


I have encountered the issue and tried several things to solve it:

  • enabled EdgePageLoadStrategy.Normal - did not help;
  • disabled the "save your password?" bubble. - did not help;
  • normalized the zoom level to 100% - bingo / eureka. This solved the issue.

My test script is a bit more performance-oriented, so I had no desire to add additional objects / capabilties / options. If you want your test to be more deployable add registry editing capabilities to your selenium script. This can be a starter: http://www.winhelponline.com/blog/microsoft-edge-disable-zoom-reset-zoom-level-every-start/

like image 43
Mindaugas Bernatavičius Avatar answered Nov 15 '22 21:11

Mindaugas Bernatavičius


I encountered the same issue on the Edge browser. It was difficult to figure out what was actually wrong, since the issue seemed to appear/disappear from time to time in my case. So at some point I decided to contact MS and created this ticket question

Here Steven K mentioned that the obscured element error is most likely due to zoom level not being at 100% So I checked and indeed it was at 125% for some reason. After I set it back to 100% the issue was resolved for me.

browser.send_keys [:control, '0']

I know this is a ruby+watir example, but I'm sure there is a similar Java trick for this.

like image 38
Mark Duivesteijn Avatar answered Nov 15 '22 21:11

Mark Duivesteijn