Im doing webtest using selenium Webdriver in C#. But I’m having a problem where when the browser window isn’t in full size a popup will open half way outside the visible area.
The problem is that when i fire a .Click(); it doesn’t do anything because the link i attempt to click is outside of the viewed area.
So how do i focus on the link to get click to work? Im currently using the following workaround but i don’t think that’s a nice way.
_blogPostPage.FindElement(By.XPath(_popupLogin)).SendKeys("");
_blogPostPage.FindElement(By.XPath(_popupLogin)).Click();
The sendkeys with space focuses on the link and makes Click work everytime, but isn’t there a right way to do it?
We’ve been playing with Selenium and have run into this problem as well. I don’t know if it’s the WebDriver as a whole, the C# implementation, the version of Firefox etc, but we have found an ok workaround:
The trick is to force Selenium to evaluate the
LocationOnScreenOnceScrolledIntoViewproperty on theRemoteWebElementclass (which is inherited byFirefoxWebElementand implementsIWebElement). This forces the browser to scroll so that the element is in view.The way we’ve done it is to use an extension method:
this way all we have to do is change the generated code from:
to:
Hope it works for you!?