Selenium says element is not visible when it is with latest Firefox (ElementNotInteractableException: Element is not visible) - selenium

On our test page we have a username field and a password field as follows:
<input required="" placeholder="USERNAME" id="usernameIdentification"
class="form-control no-upper-case autoExpand textValidation"
autofocus="autofocus" autocapitalize="none" autocorrect="off"
spellcheck="false" size="20" type="text">
<input id="password" name="password" placeholder="PASSWORD" class="form-
control no-upper-case autoExpand textValidation" required="required"
autofocus="" autocomplete="password" autocapitalize="none"
autocorrect="off" spellcheck="false" type="password" hidden="true">
The username field is filled out by selenium, we hit a next button and the next page has the password field.
Using: Firefox version 46.0.1 and Selenium version 2.53.1
The following code was working fine:
//Enter username
WebElement userField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameIdentification")));
userField.sendkeys(username);
//Press next button
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("nextButton"))).click();
//Fill password
WebElement passwordField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("password")));
passwordField.sendKeys(password);
When I update to: Firefox version 57, and selenium 3.7.1, with geckodriver 0.19.1
The code breaks, selenium will not enter text into the password field anymore, I can manually enter the password without issue, but selenium keeps insisting that the field is not visible, even though the wait check passed right before the send keys and the username field has no issues entering the text. I get this error:
> org.openqa.selenium.ElementNotInteractableException: Element is not
> visible Build info: version: '3.7.1', revision: '8a0099a', time:
> '2017-11-06T21:01:39.354Z' System info: host: 'D2QZ7XF2', ip:
> '10.122.22.31', os.name: 'Windows 10', os.arch: 'amd64', os.version:
> '10.0', java.version: '1.8.0_151' Driver info:
> org.openqa.selenium.firefox.FirefoxDriver Capabilities
> {acceptInsecureCerts: true, browserName: firefox, browserVersion:
> 57.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 15884, moz:profile:
> C:\Users\dcollier\AppData\L..., moz:webdriverClick: false,
> pageLoadStrategy: normal, platform: XP, platformName: XP,
> platformVersion: 10.0, rotatable: false, timeouts: {implicit: 0,
> pageLoad: 300000, script: 30000}} Session ID:
> b2f9536b-23ce-4c0f-93d5-cfe46d82228d
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method) at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
> at
> org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
> at
> org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
> at
> org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
> at
> org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
> at
> org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
> at
> org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
I also tested with latest Chrome driver and it worked fine there as well. But we need to use firefox profiles, so i need this to work there. Appears to be an issue with the gecko driver, has anyone encountered this, know of a solution? I tried several approaches but it never works.

Related

Caused by: org.openqa.selenium.InvalidSelectorException:

I am new in Selenium automation testing
Getting Selenium Error
When I am trying to run below code every time I got error"org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath" I am not sure what xpate will be could some one please help me
Created Automation test case for Login Application.
Java:
#Test
public void enterApplicationCerdentials(String userName, String password) {
WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//frameset/frame/html/body/div([#class='tintedBox' and #id='loginBox']/table/tbody/tr/td/input[#id='UserID' and name='UserID'])"))).sendKeys(userName);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Password"))).sendKeys("CSRWHKXESB");
captureScreen();
}
HTML:
<frameset rows="*, 1">
<frame src="Script/Login.asp?">
#document
<!--Function return the password for the user who logged in through Referral URL.
For TAFE user password is not matching as per database value as their URL is dynamic. ENHC0014091
This function splits the URL of that particular user (8527066229) only . -->
<html><head>
<script language="JavaScript">
//<!--
function OnLoad()
{
setTimeout("CheckFrame()", 4000);
}
function CheckFrame()
{
with (parent)
{
if ((length==0 && document.frmCheck==null) ||
(length>0 && frames[1].document.frmCheck==null))
{
var PathName = window.location.pathname;
PathName = PathName.substr(0, PathName.substr(1).indexOf("/") + 1);
location.href = PathName;
}
}
}
//-->
</script></head>
<body onload="OnLoad()" topmargin="0" leftmargin="0" bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<div id="login">
<img border="0" src= vspace="10" style="display: block;">
<div class="tintedBox" id="InfoStoreBox">
<h1> <a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"><u>InfoStore</u></a> ?</h1>
<p></p>
<p><a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"></a> .</p>
<p>Not only a shop, <a class="boldLink" href="https://infostore.saiglobal.com" target="_parent"></a> </p>
<p></p>
</div>
<div class="tintedBox" id="loginBox">
<h1></h1>
<form name="form" action="Login.asp?" method="post">
<input type="hidden" name="Autologout" value="false">
<input type="hidden" name="Division" value="">
<span class="error"></span>
<table>
<tbody><tr>
<td>User ID</td>
<td><input type="text" size="30" id="UserID" name="UserID" value=""></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" size="30" id="Password" name="Password" value=""></td>
</tr>
<tr>
<td>Last Name/Location</td>
<td><input type="text" size="30" id="UserName" name="UserName" value=""></td>
</tr>
</tbody></table>
<br>
<font color="#d12b2c"><nobr>Your Last Name and Location are now mandatory to access the platform, simply</nobr><br>enter the details in field (e.g. Smith/Perth)</font>
<br><br>
<div>
<input type="checkbox" id="SaveLogin" name="SaveLogin" value="SaveLogin"><label for="SaveLogin" id="save">Save my login so you can remember me on my next visit.</label>
</div>
<div align="center" style="padding-top:20px">
<input class="button" type="submit" name="Submit" value="Submit">
<input class="button" type="reset" name="Clear" value="Clear">
<input class="button" type="submit" name="Recognize" value="Remember me?">
</div>
<div style="padding-top:20px">
<nobr>Lost password? Contact your internal Administrator or <a class="boldLink" href="mailto:sales#saiglobal.com?subject=Lost SOL password">our Customer Service</a></nobr>
</div>
</form>
</div>
</div>
<div id="footer" onmouseover="ShowTime()">©2014 SAI Global</div>
<script>
function ShowTime()
{
var spTime = document.getElementById("footer");
spTime.innerHTML = "©2014 SAI Global - 20190426 12:25:33.292: 172.20.33.12, 203.27.21.6, 59596377";
}
</script>
</body></html>
Error:
org.openqa.selenium.TimeoutException: Expected condition failed:
waiting for visibility of element located by By.xpath:
//frameset/frame/html/body/div([#class='tintedBox' and
#id='loginBox']/table/tbody/tr/td/input[#id='UserID' and
name='UserID']) (tried for 50 second(s) with 500 milliseconds
interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at seleniumPages.Page_LoginMyApplication.enterApplicationCerdentials(Page_LoginMyApplication.java:67)
at stepDefinitions.StepDefs_DataDrivenLogin.i_login_with_credentials_and(StepDefs_DataDrivenLogin.java:23)
at ?.I login with credentials "tomsmith" and "***************"(resources/features/DataDrivenLogin.feature:7) Caused
by: org.openqa.selenium.InvalidSelectorException: invalid selector:
Unable to locate an element with the xpath expression
//frameset/frame/html/body/div([#class='tintedBox' and
#id='loginBox']/table/tbody/tr/td/input[#id='UserID' and
name='UserID']) because of the following error: SyntaxError: Failed to
execute 'evaluate' on 'Document': The string
'//frameset/frame/html/body/div([#class='tintedBox' and
#id='loginBox']/table/tbody/tr/td/input[#id='UserID' and
name='UserID'])' is not a valid XPath expression. (Session info:
chrome=73.0.3683.103) (Driver info: chromedriver=2.46.628402
(536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT
6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For
documentation on this error, please visit:
https://www.seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '3.141.59', revision: 'e82be7d358', time:
'2018-11-14T08:25:48' System info: host: 'AP01154W8N', ip:
'192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version:
'6.3', java.version: '1.8.0_191' Driver info:
org.openqa.selenium.chrome.ChromeDriver Capabilities
{acceptInsecureCerts: false, acceptSslCerts: false,
applicationCacheEnabled: false, browserConnectionEnabled: false,
browserName: chrome, chrome: {chromedriverVersion: 2.46.628402
(536cd7adbad73a..., userDataDir: C:\Users\sinham0\AppData\Lo...},
cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions:
{debuggerAddress: localhost:65139}, handlesAlerts: true,
hasTouchScreen: false, javascriptEnabled: true,
locationContextEnabled: true, mobileEmulationEnabled: false,
nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy:
normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable:
false, setWindowRect: true, strictFileInteractability: false,
takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit:
0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore,
unhandledPromptBehavior: ignore, version: 73.0.3683.103,
webStorageEnabled: true} Session ID: 869efd2308887ee98e8d561566b5a606
*** Element info: {Using=xpath, value=//frameset/frame/html/body/div([#class='tintedBox' and
#id='loginBox']/table/tbody/tr/td/input[#id='UserID' and
name='UserID'])}
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
The reason you are getting TimeoutException is that the element you are finding is in a frame and you have to switch to that frame. Otherwise, webdriver can't find the element.
First, find the appropriate selector for the frame tag. According to your provided HTML I'm constructing the locator.
XPath:
WebElement loginFrame = driver.findElement(By.xpath("//frameset/frame[#src='Script/Login.asp?']"));
CSS Selector:
WebElement loginFrame = driver.findElement(By.cssSelector("frameset > frame[src='frame_c.htm']"));
Try this:
#Test
public void enterApplicationCerdentials(String userName, String password) {
WebDriverWait wait = new WebDriverWait(driver, 50);
By frameLocator = By.xpath("//frameset/frame[#src='Script/Login.asp?']");
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//frameset/frame[#src='Script/Login.asp?']")));
driver.switchTo().frame(driver.findElement(frameLocator));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("UserName"))).sendKeys("UserName");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Password"))).sendKeys("Password");
captureScreen();
}

unable to click on a tab using selenium java for extjs applicaton

I'm trying to select a tab on webpage created using extjs. FirePath is highlighting the tab correctly but click event is not working. Selenium is throwing element not visible error.
Exception in thread "main"\org.openqa.selenium.ElementNotVisibleException: element not visible
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7601 SP1 x86_64)
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 38 milliseconds
Here is the HTML code:
I'm trying to select a Tab titled Details with id as tabDetail.
<a class="x-tab x-unselectable x-box-item x-tab-default x-noicon x-tab-noicon x-tab-default-noicon x-top x-tab-top x-tab-default-top x-tab-after-title" role="button" hidefocus="on" unselectable="on" tabindex="0" id="tabDetail" style="right: auto; left: 143px; top: 0px; margin: 0px;">
<span id="tabDetail-btnWrap" class="x-tab-wrap" unselectable="on">
<span id="tabDetail-btnEl" class="x-tab-button">
<span id="tabDetail-btnInnerEl" class="x-tab-inner x-tab-inner-center" unselectable="on">
Detail
</span>
<span role="img" id="tabDetail-btnIconEl" class="x-tab-icon-el " unselectable="on" style="">
</span>
</span>
</span>
</a>
You need to wait until element is visible. Use explicit wait -
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[2]")));
// Now click on element
driver.findElement(By.xpath("//div[2]")).click();

Element is not clickable at point ... with selenium 2 and WebDriver

today I searched a lot and found lots of information, but nothing helped.
I use selenium-java-2.53.1 and FF47 and face the following problem:
Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (779.5, 12.199996948242188). Other element would receive the click: <header class="header"></header>
Command duration or timeout: 106 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'spa-PC', ip: '192.168.5.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_74'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=47.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c897bef8-b708-45f3-a991-5cf8971939c8
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
It happens when I running this code:
WebElement elementToClick = driver.findElement(By.xpath("//div[#class='show show-hide-accounts-button']"));
elementToClick.click();
And use this part of HTML:
<div class="trader-wrapper">
<a class="avatar-frame-small" href="/bg/traders/5d2f970c-56e9-4ca1-99de-13ecb266bc82">
<span class="flag flag-lt" title="Литва"></span>
<a class="profile-link" href="/bg/traders/5d2f970c-56e9-4ca1-99de-13ecb266bc82">
<div class="trader-current-time">
<div class="accounts-summary">
<button class="follow-trader-ribbon" title="Start receiving trading activity updates from this Trader" data-user-name="Justinas Miezis" data-follow="53121">Follow </button>
<table class="trader-info">
<div class="gain-chart-wrapper trader">
<div class="clear"></div>
<div class="show show-hide-accounts-button">Show account</div>
<div class="angled-separator top">
<div class="trader-accounts">
<div class="angled-separator bottom"></div>
</div>
Does somebody have workaround for this problem?
Thank you in advance.

Selenium Error:I am using selenium webdriver in maximo for testing but some error

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (413, 63). Other element would receive the click: <div id="wait" width="100%" height="100%" class="wait" style="position: absolute; top: 0px; left: 0px; height: 666px; width: 1366px; display: block; cursor: wait;">...</div>
(Session info: chrome=53.0.2785.143)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 94 milliseconds
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'ICDVM', ip: '10.0.0.11', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\ADMINI~1\AppData\Local\Temp\scoped_dir16420_7494}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=53.0.2785.143, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e24f7435d75ad5ddbecb362090ddb0a3
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:631)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:284)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at script.Script.main(Script.java:78)
For what its worth, there is an element with a wait class overlaying the element you are trying to click.

How do I check enable and disabled button using helium?

The code of attached button is:
<div style="position: absolute; right: 0; top: 0;">
<button class="prev btn btn-warning disabled" style="padding: 4px 8px;">
<i class="fa fa-chevron-left" style="margin: 0"/>
</button>
<button class="next btn btn-warning" style="padding: 4px 8px;">
<i class="fa fa-chevron-right" style="margin: 0"/>
</button>
</div>
How can I check that which one is enable using helium
I tried the following code
click("Home");
if(Button(">").isEnabled()){
click($("html/body/div[6]/div/h3/div/button[2]"));
}
else{
click($("html/body/div[6]/div/h3/div/button[1]"));
}
But got the following error
Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Cannot find element ButtonImpl(">").
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27
09:10:26'
System info: host: 'Keya-PC', ip: '172.16.0.144', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.8.0_25'
Driver info: driver.version: unknown
at com.heliumhq.api_impl.GUIElementImpl.perform(GUIElementImpl.java:107)
at com.heliumhq.api_impl.GUIElementImpl.bindToFirstOccurrence(GUIElementImpl.java:94)
at com.heliumhq.api_impl.GUIElementImpl.getFirstOccurrence(GUIElementImpl.java:89)
at com.heliumhq.api_impl.ButtonImpl.isEnabled(ButtonImpl.java:26)
at com.heliumhq.API$Button.isEnabled(API.java:1276)
at searchHomePage.search(searchHomePage.java:30)
at mainClass.main(mainClass.java:19)
error: Cannot find element ButtonImpl(">")
We need to check the presence of the class (prev btn btn-warning disabled or next btn btn-warning ) in the code.
element ">" is not on the page is a picture.
UPD:
if (driver.findElements(By.xpath("someXpath")).size == 0)
or
$(By.xpath("someXpath")).shouldNotBe(visible);
Code in Java:
public static boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}