Elements are not get in IE Browser. i am using IE 11 Browser. While I am run my code then Error is displaying in my consol as Started InternetExplorerDriver server (32-bit) 2.47.0.0
Listening on port 20577
Error show := org.openqa.selenium.NoSuchElementException: Unable to find element with id == Id_user_name_id (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.17 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'VDJSDEV2-PC', ip: '172.16.1.220', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:20577/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 8bd16d35-c13d-46f7-b6cf-f9a7ddd54dda
*** Element info: {Using=id, value=Id_user_name_id}
And I am using these Jar files
selenium-server-standalone-2.47.1.jar
selenium-ie-driver-2.47.0.jar
selenium-java-2.47.1-srcs.jar
selenium-java-2.47.1.jar
IEDriverServer_Win32_2.47.0
I found the same problem, and my solution is:
Modified IE setting to display both secure and non secure contents.
Set the Protected Mode settings for each zone to be the same value, the value can be on or off, as long as it is the same for every zone (I checked "Enable Protected Mode" all).
Way to set protected mode: choose "Internet Options..." from the Tools menu -> click on the Security tab. For each zone (Internet/Local Internet/Trusted Web Sites/Restricted Sites), check the check box at the bottom of the tab labeled "Enable Protected Mode".
Restart your IE browser.
It works on me, hope it can help you too.
Some suggestion which may help.
Check the element id is unique in the page and actually exist; can you post the html page ( just the element and its parent parent if possible)
Increase the browser capabilities timeout to double the existing one
before you search for the element by id
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Try with different Driver (Firefox or Chrome) and see if the problem persist
Try to search the element by selector; if you post the html page, I can help in sending some suggestion
Cheers
Alan Mehio
London
Related
Selenium code to highlight an element is working only on one of the system.
I have updated chrome and chrome driver on both of them but in one machine, it works but code breaks on another machine when trying to highlight the page element.
Below is the exception:
An error occurred while fetching element : Expected condition failed: waiting for visibility of element located by By.id: body_x_grid_x__ctl2__ctl0 (tried for 15 second(s) with 500 MILLISECONDS interval)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '**', ip: '**', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab), userDataDir=**}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=67.0.3396.99, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 9854688adcdbe56519b9869c496b58e2
at com.selenium.element.action.Wait.elementAction(Wait.java:68)
....
It does not find the element within specific periods and breaks.
This error message...
An error occurred while fetching element : Expected condition failed: waiting for visibility of element located by By.id: body_x_grid_x__ctl2__ctl0 (tried for 15 second(s) with 500 MILLISECONDS interval)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '**', ip: '**', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
...implies that the ChromeDriver was unable to interact with the WebElement returned after WebDriverWait.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Your Selenium Client and ChromeDriver versions are not getting detected back.
Your JDK version is 1.8.0_77 which is pretty ancient.
So there is a clear mismatch between the JDK v8u77 and the latest Selenium Client v3.13.0 , ChromeDriver v2.40 and the Chrome Browser v67.0
Solution
Upgrade JDK to recent levels JDK 8u172.
Upgrade Selenium to current levels Version 3.13.0.
Keep ChromeDriver to current ChromeDriver v2.40 level.
Keep Chrome version between Chrome v66-68 levels. (as per ChromeDriver v2.40 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Execute your #Test.
Wrap your code in a try/catch clause, and inside the catch save the content of webdriver.getPageSource(). Then examine its content (you may even be able to open it in the browser if you name the file with a .html extension) and see whether an element with id='body_x_grid_x__ctl2__ctl0' actually exists.
I'm not sure, but it looks like this id was generated automatically by the application, and may be generated somewhat differently on the other machine.
Your problem is not with highlighter, it's with your webElement:
An error occurred while fetching element : Expected condition failed: waiting for visibility of element located by By.id: body_x_grid_x__ctl2__ctl0 (tried for 15 second(s) with 500 MILLISECONDS interval)
Increase the wait time because your existing wait in 15 sec: increase according to your website page load maximum time:
WebDriverWait wait = new WebDriverWait(driver, wait time in second);
WebElement we = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("your xpath")));
After getting the webElement you can go for highlighter by using below code:
public void highLighter(WebDriver driver, WebElement we) {
try{
JavascriptExecutor js = (JavascriptExecutor)driver;
String var = (String) js.executeScript("return arguments[0].getAttribute('style', arguments[1]);", we);
js.executeScript("return arguments[0].setAttribute('style', arguments[1]);", we,"border:4px solid red;");
Thread.sleep(200);
js.executeScript("return arguments[0].setAttribute('style', arguments[1]);", we,var);
}catch(Exception e){
System.out.println("unable to HighLight");
}
}
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'.
Safari 10.0.1
macOS Sierra
When running Codeception command:
$I->waitForElementVisible(['css' => 'input[type=text][id=UserUsername]'], 30);
in an acceptance test in Safari with Selenium 3.0.1 I receive an error. The screenshot taken at failure clearly displays the element in question. The same test/command is successful in both Firefox and Chrome. The error:
Screenshot saved to /Applications/MAMP/htdocs/AutomatedTests/tests/_output/debug/FAILED1479307207.png
Unable to retrieve Selenium logs : The command 'GET /session/9BC56414-8934-4315-9293-B6E99720E318/log/types' is not implemented.
Command duration or timeout: 3 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'Cosettes-MacBook-Pro.local', ip: '10.0.1.75', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.1', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true, handlesAlerts=true, version=12602.2.14.0.5, cleanSession=true, platform=MAC, nativeEvents=true, locationContextEnabled=false, webStorageEnabled=true, browserName=safari, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 9BC56414-8934-4315-9293-B6E99720E318
Screenshot and page source were saved into '/Applications/MAMP/htdocs/AutomatedTests/tests/_output/' dir
ERROR
When I run the same test/command in Safari/Firefox/Chrome with Selenium 2.53.1 it finds the element with no problems.
Is there a known issue with this type of locator I'm not finding when going through the forums? Anyone have a suggestion for how to make this work?
Update 12-01-16: This now seems to be more of an issue with waitForElementVisible() command than the Locator. If I change the command to $I->waitForElement(['css' => 'input[type=text][id=UserUsername]'], 30); the test successfully moves forward till the next waitForElementVisible() command.
People say visibility checks are broken in the release version of Safari 10. You can try Safari Technology Preview, and if your issue is still there, we can conclude it's some other issue, not the broken visibility checks. If your issue is gone, it'll be not exactly your users' experience, but better than nothing anyways. Also you can try implementing your own visibility checks as a workaround using some script on the browser's side (e.g. this function looks good enough).
To run your tests in Safari Technology Preview, add
'safari.options': { technologyPreview: true }
to the capabilities.
See also my other answer on this subject.
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.
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()