0
votes
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 21 milliseconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_25'
Session ID: 16492097-714b-42c4-b9dc-2c3979db180f
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=22.0}]

The results of the executed scripts are not consistent. Sometimes it passes, and sometime it throws the exception mentioned above.

2
I'd suggest trying a delay, either a short Sleep, or a waitforelement. - Richard
At the very least it's time to upgrade your versions. v2.32 of Selenium and v22 of Firefox? We are at v2.41 of Selenium and v29 of Firefox. Time to upgrade. - Arran
Hi Arran, I am using Mozilla version 28.0 and Selenium 2.32. If I will upgrade it to the new version will my earlier running scripts will run sucessfully? I dont want to get new errors on version upgrade. Please let me know ASAP. Thanks in advance. - user2301442
Richard I am already using Sleep but its not working with it - user2301442

2 Answers

0
votes

The script result is not same because the element might talking different amount of time for appear on page.

Using sleep can solve the problem but that is not good practice as you may have to adjust/increase the value if test case failed even after giving sleep.

Better use wait for element functionality.

Refer document @ "http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp" for details

0
votes

yes You need to use a conditional wait , so that your code will wait until it locates the element.

For Example:If you are using web-driver

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")));