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.
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");
}
}
Does anyone know how to setup the Microsoft Edge browser with Protractor?
I'm using Protractor (Javascript) and Gulp; NOT Java or C#.
Here's my Protractor config file:
exports.config = {
framework: 'cucumber',
seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/selenium/MicrosoftWebDriver.exe'],
multiCapabilities: {
'browserName': 'MicrosoftEdge',
javascriptEnabled=true,
//'platform': 'windows',
// 'version': '11'
}
,
{
'browserName': 'chrome',
loggingPrefs: {
driver: 'DEBUG',
server: 'INFO',
browser: 'ALL'
}
}],
}
1. I specify the browser name which is 'MicrosoftEdge' then
2. I thought I would point to the EdgeDriver.exe just like I did and it worked for the IE browser.
What else am I missing, this successfully opens up the Edge browser but fails to navigate to a URL with error
var template = new Error(this.message);
^
UnknownError: null (WARNING: The server did not provide any stacktrace information)
Has anyone successfully set up Microsoft Edge with Protractor/CucumberJS?
I just had the same problem as you outlined,I noticed you and I are running the same build of Windows 10,
I have managed to find a solution to my problem if you see the small print around the download link on https://msdn.microsoft.com/en-us//library/mt188085(v=vs.85).aspx
You'll notice there are three driver versions try install the following one:
Windows 10 Fall 2015 Update, install Microsoft WebDriver Fall 2015 Update.
From the install directory take the 'MicrosoftWebDriver.exe' and replace your current one.
I think you are looking for is the Browser Fingerprint.
While not complete (including MS-Edge), it should point you in the correct direction..
https://en.wikipedia.org/wiki/Device_fingerprint#External_links
Especially - http://www.darkwavetech.com/fingerprint/fingerprint_code.html
Hope this helps!
I ended up doing the following to get Mircosoft Edge to launch from Protractor.
Here's where I got the driver for Microsoft Edge (https://www.microsoft.com/en-us/download/details.aspx?id=48212); you can install the .msi file and it'll give you a .exe which you can drop in to a location of your choice:
Here's my config file for Microsoft Edge:
exports.config = {
framework: 'cucumber',
//Microsoft Edge
seleniumArgs: ['-Dwebdriver.edge.driver=node_modules/protractor/selenium/MicrosoftWebDriver.exe'],
capabilities: {
'browserName': 'MicrosoftEdge',
'platform': 'windows',
// 'version': '11'
},
}
Please note if you wanted to just get IE11 then you would use this instead and make sure to point it to wherever you downloaded the ieDriver (http://www.seleniumhq.org/download/) to your local machine:
seleniumArgs: ['webdriver.ie.driver=node_modules/protractor/selenium/IEDriverServer.exe'],
And don't forget to change the browser name to 'browserName': 'internet explorer',
This is just a step closer to getting Protractor(Javascript and Gulp, please NO Java or C#) to work with Microsoft Edge on Windows 10 OS, this launches the Microsoft Edge browser; however I am still running into issues such as:
var template = new Error(this.message);
^
UnknownError: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6.95 seconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'DEV-6', ip: '10.10.50.25', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.edge.EdgeDriver
at new bot.Error
This is a work in progress so I'll update this post as I get more meaningful results; if anyone knows of how to avoid this error to successfully automate Microsoft Edge with Protractor please suggest it here.
And please note I am NOT using the Java or C# bindings which seem to be very popular on Google results; instead I am using Protractor with Javascript and gulp for my e2e tests. Any help much appreciated thanks.
For those who want to start a protractor test with edge, here is the relevant part of my protractor.conf :
seleniumArgs: ['-Dwebdriver.edge.driver=node_modules/protractor/selenium/MicrosoftWebDriver.exe'],
baseUrl: 'http://127.0.0.1:4321/index_protractor.html',
capabilities: {
'browserName': 'MicrosoftEdge'
},
So it's a mix between all you can read on the Internet (note that the case is important with MicrosoftEdge).
On the upside, Edge is started and I see the url changing, etc
On the downside, every test I tried failed with this error :
Message:
Failed: Error while running testForAngular: not implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'PORTABLE-SL3', ip: '192.168.43.171', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.edge.EdgeDriver
Capabilities [{acceptSslCerts=true, browserVersion=20.10240.16384.0, platformVersion=10, browserName=MicrosoftEdge, takesScreenshot=true, pageLoadStrategy=normal, takesElementScreenshot=true, platformName=windows, platform=ANY}]
Session ID: 732EDD82-B245-4020-8B0E-3FBE0428AAB6
So I guess the driver is not ready for Angular
EDIT:
Confirmed, adding this line before my browser.get fixed my error
browser.ignoreSynchronization=true;
I had to handle the wait for Angular manually though. Please note also that by.repeater was not working
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
I am using chrome browser in selenium project.
Here is the user agent string that I am using:
System.setProperty("webdriver.chrome.driver","C:\\users\\..\\chromedriver.exe");
driver = new ChromeDriver();
What happens IF I run the script:
It open the chrome browser and after some time it close it and giving error:
org.openqa.selenium.WebDriverException: unknown error: unable to
discover open pages (Driver info: chromedriver=2.2,platform=Windows
NT 6.1 x86) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 26.83 seconds Build info:
version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'QAVM-9', ip: '27.101.1.26', os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45' Driver
info: org.openqa.selenium.chrome.ChromeDriver at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at
org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:182)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:115)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:161)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:150)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:139)
Please help me, It completely stop the execution.
Let me know in case need any other information.
I would suggest you to update your chrome driver since your version is 2.2 and the latest is 2.9. It might be possible that your existing chrome driver might not be supporting your chrome browser if the browser is of latest version.
Chrome driver versions are here
Also check the release notes here. Each chromedriver mentions which chrome browser versions
it supports.
Here's what I did to get rid of that error (
unknown error: unable to discover open pages
)
In your protractor config file, add the following:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox']
}
},
The most important line there is the --no-sandbox; adding that line somehow gets rid of that error.
I am not exactly sure why it works but it's a workaround I found while digging around online.
I am working on writing Behat tests for an old bojankity system written in PHP. It seems to work for a number of test cases. However I am running into a strange problem.
I have Behat logging in and navigating to the search form page. Then it fills out the form by selecting a few drop-downs and filling in a text field. And then clicking the search button (keeping in mind that the button and some of the drop-downs have some JS actions attached to them). All of those actions pass, but on the next step after I run 'Then I press "Search"' I get the following error/message:
Then I wait five seconds # FeatureContext::iWaitFiveSeconds()
Modal dialog present
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.5.0-31-generic', java.version: '1.6.0_43'
Session ID: 13badfa6-9847-4db4-901f-fcfde797df92
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=21.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
This is running through the Selenium 2 driver. The context function mentioned here is just a JS wait call. I use it and variations on it in several places. The same thing happens when I do other things at this point instead of waiting, such as checking for certain text on the page.
Any idea what might be going on? By the way, this is for an internal web app, so there are no URLs I can give out. I should also add that I am running this on Ubuntu 12.10 with PHP 5.3.
Thanks!
This could be caused due to an AJAX call messing with the flow of the test. make sure you give enough time for your AJAX requests to complete in the previous scenarios.
Best