I tried to implement a test suite using selenium.
While writing the automated script, the driver is able to enter the data using xpath. In the result I can see the value entered into the text box, but while saving the page throws error that data is not entered in to the column(Stale element Exception).
To solve this, I tried to move the focus out and get back to the column and enter the data again. Still I am getting the same kind of error.
Error Message:
Element not found in the cache - perhaps the page has changed since it
was looked up For documentation on this error, please visit:
http://seleniumhq.org/exceptions/stale_element_reference.html Build
info: version: '2.47.1', revision: '411b314', time: '2015-07-30
03:03:16' System info: host: 'HQ04HQQTP006', ip: '10.10.220.164',
os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.8.0_66' Driver info: driver.version: unknown Command duration or
timeout: 8.17 seconds For documentation on this error, please visit:
http://seleniumhq.org/exceptions/stale_element_reference.html Build
info: version: '2.47.1', revision: 'unknown', time: '2015-07-30
11:02:44' System info: host: 'HQ-GRID-001', ip: '10.10.1.206',
os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1',
java.version: '1.8.0_65' Driver info:
org.openqa.selenium.remote.RemoteWebDriver Capabilities
[{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true,
databaseEnabled=true, version=40.0.3, platform=WINDOWS,
nativeEvents=false, acceptSslCerts=true,
webdriver.remote.sessionid=b95bec47-70a6-4c88-bbc0-e38c9d56aff0,
webStorageEnabled=true, locationContextEnabled=true,
browserName=firefox, takesScreenshot=true, javascriptEnabled=true,
cssSelectorsEnabled=true}] Session ID:
b95bec47-70a6-4c88-bbc0-e38c9d56aff0
Please let me know if I am not clear in the question, I will try to explain it more.
I have two tips for you to try here:
After doing sendKeys do sendKeys(Keys.TAB) on same element or click some other text box. The point of doing this here is There might be some fields that update data after you enter something into other field. Example : Actual column.
Now after this is done and you see the data entered correctly, you need to give some time to your save button in case if it was disabled initially. In this case, use:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.YOUR LOCATOR));
Here I would recommend that you mention the locator and Not a previously identified element, since refreshing etc. may corrupt previously identified elements.
Related
I am trying to upgrade my project from Selenium 3.0.0beta4 to 3.6.0. I want to set the timeout for page loading with
driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);
This, however, crashes the application:
Exception in thread "main" org.openqa.selenium.InvalidArgumentException:
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'machine.example.org', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.88', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=/tmp/rust_mozprofile.AZHGaB47hL8x, rotatable=false, timeouts={implicit=0, page load=300000, script=30000}, pageLoadStrategy=normal, platform=LINUX, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=52.4.0, platformVersion=4.4.88, moz:processID=10959, browserName=firefox, javascriptEnabled=true, platformName=LINUX}]
The value is not changed. I am using geckodriver v0.18.0 and Firefox 52.4.0.
Is there any limitation on the Firefox version I can use?
In the Selenium 3.0.0beta4 version of my application I set the following property for the gecko driver:
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");
After I changed the property to
System.setProperty("webdriver.firefox.marionette", "/path/to/geckodriver");
in the Selenium 3.6.0 version my application started working again. I use Firefox v45.9.0 and geckodriver v0.18.0. Other combinations may work, too.
I can able to see the FF[53.0.2] opened. But, I am getting an "error Unable to create new remote session". Could any one help out?
Environment :
Windows 7 64 bit
FF - 53.0.2 (32bit)
Selenium 3.4
Geckdriver 0.16 and 0.16.1[win 32]
Problem :
Unable to create a new remote session. But, driver initiated the FF [blank browser].
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\src\\Drivers\\geckodriver-v0.16.0-win32\\geckodriver.exe");
DesiredCapabilities caps2 = DesiredCapabilities.firefox();
caps2.setBrowserName("firefox");
caps2.setPlatform(org.openqa.selenium.Platform.WINDOWS);
driver1= new RemoteWebDriver(new URL(node),caps2);
Actual output :
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}, version=, platform=VISTA}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'XXXXXXXXX', ip: 'XXX.XXX.XX.XXX', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: FirefoxDriver
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'XXXXXXXXX', ip: 'XXX.XXX.XX.XXX', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: FirefoxDriver
Why don't you try replacing this
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\src\\Drivers\\geckodriver-v0.16.0-win32\\geckodriver.exe");
With this:
System.setProperty("webdriver.gecko.driver", "explicit path to your geckodriver);
I got this issue resolved.While setting up a node, i gave the configuration as geckodriver-v0.16.1-win32. Irrespective of setting other properties, it didn't change.Simple one, but i took a long way to explore. Anyways, thank you guys.
I'm trying to test search UI using selenium web driver in java
If I click on result it shows some properties of that results.
So now when I click on first result, the webdriver is able to locate those properties by FindElementsByXpath("//li[#class='clickable ng-binding ng-scope']")
Also tried findElementsByCss("*[class='clickable ng-binding ng-scope']")
But when webdriver clicks on second result, it shows up their properties but webdriver is UNABLE to locate properties (have same class name as first).
Any help here?
can't use Xpath since ids are unique and different.
i click result using this-
findElement(By.xpath("/html/body/div[1]/div/div/div[1]/div[2]/div[1]/div[2]/div/els-result["+num+"]/div")).click();
where num is result number
*Stack trace here
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of all elements located by By.cssSelector: *[class='clickable ng-binding ng-scope'] (tried for 15 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
System info: host: '', ip: '', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.3', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20170125094131, version=, platform=MAC, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=22487, browserVersion=51.0.1, platformVersion=16.4.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=darwin, firefox_profile=UEsDBBQACAgIAOl6aUoAAAAAAAAAA..., unexpectedAlertBehaviour=dismiss}]
Session ID: df2df541-1966-5a4b-871c-7cd8c295f4eb
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:257)
at cucumber.stepdefination.DataSearch.FindElementsByCss(DataSearch.java:166)
at cucumber.stepdefination.AssestCountSD.assest_count_matches_list(AssestCountSD.java:76)
at cucumber.stepdefination.AssestCountSD.for_each_source_assest_count_matches_that_in_list_on_right(AssestCountSD.java:51)
at ✽.Then For each source assest count matches that in list on right(/Users/malikh/Documents/workspace/cucumber/src/test/resource/assetCount.feature:6)
I would suggest to use Firefox browser and install one of its extensions called 'Firepath'. This would help you to locate a UI element using both 'Xpath' and 'CSS'.
I want to enter the captcha text manually so how to write the code for this?
Here is my code:
driver.findElement(By.name("/atg/commerce/order/purchase/CommitOrderFormHandler.userCaptcha")).sendKeys(captcha);
I am getting below error :
Element is not currently visible and so may not be interacted with Command duration or timeout: 9 milliseconds Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15' System info: host: 'WID1376', ip: '172.21.22.76', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35' Session ID: 65dab209-84aa-436a-915f-7a52174405a5 Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=23.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
If you want to enter the value manually...place an explicit wait (eg: thread.sleep(20000);) and enter the captcha text manually within 20sec. This may help you. If not read the links provided by TDHM and olyv
Hi I am beginning to start automating some tests. I am trying to verify that certain submenu options exist when you hover over the dropdown menu. But I get an error returned from PHPUnit:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 16 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'WIN-5FCJ9IIGCSP', ip: '192.168.31.128', os.name: 'Windows Server 2008 R2',
os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Session ID: 9fad5b24-2a1e-472d-bb36-b8914b3a92c2
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=27.0.1}]
I have been searching the web and would appreciate any help
Thanks
Conor
Before you search for the element(dropdown)
Try to put a:
sleep(3); // This will make it sleep for 3seconds
Or waitForElementPresent could work aswell.
And see what you get. Selenium might think that the page is already loaded and tries to find the element which isn't loaded yet: Element is not currently visible
I'm also at the very beginning of selenium, but here is a solution I wrote for clicking a dropdown element
for($tick=0 ; $tick<5 ; $tick++){
$this->moveto($this->byCssSelector('#dropDown'));
}
$this->byLinkText("Settings")->click();
If I didn't wrap the moveto() with the for loop, it would just hover momentarily and didn't work, so the ticking kept it hovered.
I suggest you to use the waitUntil() function and check when your element is displayed()