Using Geb and the Edge WebDriver I get failed to create driver from callback - selenium

In my current automation project I am attempting to automate my testing based on various browsers using Gradle and Geb. I've been able to get all browsers working with the exception of Microsoft Edge. Currently I am seeing:
geb.driver.DriverCreationException: failed to create driver from
callback
I've verified that I am downloading the MicrosoftWebDriver.exe to the expected directory in my project but I am not sure if I am missing something in my driver setup:
driver = {
EdgeOptions options = new EdgeOptions()
options.pageLoadStrategy("eager")
edgeDriver = new EdgeDriver()
return edgeDriver
}
I am fairly new to Geb and Gradle as a whole so it is entirely possible I am missing something. Any help would be appreciated.

As far as I am aware You need more than just the exe to use the MS Webdriver. The machine that's executing the Webdriver code will need to have one of the following MSI's installed:
For Windows 10 Build 10240, install this version of Microsoft WebDriver.
For Windows 10 Fall 2015 Update, install Microsoft WebDriver Fall 2015 Update.
For the latest preview build from the Windows Insider Program, install this version of Microsoft WebDriver.
I think the MSI changes some switches in Edge to enable it to be controlled by Web driver.

Turns out that my issue was due to having just upgraded my local machine to Windows 10 and the Microsoft Web Driver preview build requires the Fall 2015 update which is unavailable to me for 31 days.

Related

TFS 2015 failing to run selenium specflow tests

I'm struggling to get TFS 2015 to run my selenium specflow tests. The automation is for our production environment so the TFS project doesn't need to deploy the website code, it just needs to run the automation agaist www. (The automation code has the www address coded into it)
I've seen the chrome driver sandbox parameter although that hasn't removed my problem. I've added the following when initializing my chrome driver, shown below
Use of chrome sandbox
var options = new ChromeOptions();
options.AddArguments("–no-sandbox"); // also tried "--no-sandbox"
return new ChromeDriver(options);
TFS Command line build step settings
Tool: packages/NUnit.ConsoleRunner.3.6.1\tools\nunit3-console.exe
Arguments: "../../../My.Automation/bin/Debug/My.Automation.dll" --where "cat=demo
Working folder: $/UAT Automation/Dev/SourceCode
Error experienced on TFS (it works locally on my machine)
I get the same error when I run the command on the server myself.
Unknown error: cannot find chrome driver
Few ideas:
Check repository. Probably you didn't checkout folder with chrome
driver (you have it locally, but not in repo)
You have a path to chrome driver in code, and it is different from the path in TFS server

Is there a Selenium WebDriver available for the Microsoft Edge browser?

As of the date of this post the name "Microsoft Edge" has just been officially announced as the default browser for the new Windows 10.
It may be premature to ask but I would like to know if a new Selenium WebDriver is available for it and if not, if there is any telling how long we might expect to wait until we see one developed?
(A technical preview of Windows 10 has already been out so this doesn't seem like a foolish question to me.)
Yes, there is a WebDriver implementation for Microsoft Edge. Its initial availability was announced on 23 July 2015. Language bindings in the Selenium open source project have been updated to take advantage of this driver implementation, and those updates have been released in Selenium 2.47. Note that the Java language bindings were re-released as 2.47.1 to correct an initial issue. The initial implementation has limited functionality, but Microsoft is committed to bringing a fully functional driver implementation to fruition, so updates will be forthcoming.
Microsoft has provided MicrosoftWebDriver which can be used for Edge browser.
Correct version of MicrosoftWebDriver needs to be downloaded, based on the OS Build number
Go to Start > Settings > System > About and note down the OS Build number.
Download the proper version of the driver from this link - https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
If the file that's downloaded is .msi, then install it to get the .exe driver. For one of the release, direct .exe can be downloaded.
Once the MicrosoftWebDriver.exe is downloaded, we can use it in our test script using either System.setProperty("webdriver.edge.driver", "driver location") or using environment variable
The sample script would be like this -
System.setProperty("webdriver.edge.driver","C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe"); //put actual location
WebDriver driver = new EdgeDriver();
driver.get("your link");
Refer this article for detailed information - http://automationtestinghub.com/selenium-3-launch-microsoft-edge-with-microsoftwebdriver/
The Microsoft Edge driver for Selenium can be automatically downloaded (for Java) using the library webdrivermanager as follows:
EdgeDriverManager.getInstance().setup();
The variable webdriver.edge.driver is also exported by webdrivermanager with the proper path of MicrosoftWebDriver.exe.
"in case it wasn't clear, Microsoft Edge will have WebDriver support. It isn't available today, but is in development Q's? #msedgesummit" tweet from John Jansen the who is - "Microsoft Engineer. Principal Software Engineer (nee Test) Lead on Project Spartan (nee Internet Explorer)."
You can find him on twitter #thejohnjansen and wait for an announcement :)
Prerequisite: Windows 10 is installed on your machine
Download the specified Microsoft WebDriver server version for your build (In my case it is MicrosoftWebDriver.exe for the Operating System: Windows 10 Pro 64-bit (10.0, Build 14393))
Selenium WD Java code for MS Edge is as follows:
System.setProperty("webdriver.edge.driver", "D:\Ripon\MicrosoftWebDriver.exe");
driver = new EdgeDriver();
As of EdgeHTML version 18 (which arrived with Windows version 1809), there is no longer a standalone driver download. You can obtain the new driver in one of two ways:
Start - type "Manage optional features" - Click "Add a Feature" - Find "WebDriver"
Entering the following on an elevated command prompt - "DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0"
https://blogs.windows.com/msedgedev/2018/06/14/webdriver-w3c-recommendation-feature-on-demand/#Qj75uxuFHccPmCW5.97
Legacy versions are still available from:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Update:
It appears that version 18 is now legacy and we are back to installing a separate webdriver since the move to Chromium. The link directly above this will still take you to the correct drivers page.
Thanks for your help, I was blocked with my tests, searching for a "EdgeDriver.exe" asked by the selenium EdgeDriver implementation and only find the MicrosoftWebDriver.
I have made this in C# if this can help someone, based on your previous answers :
First, you need to download the MicrosoftWebDriver nuget package, this one will only make a copy of the MicrosoftWebDriver.exe into your destination folder on compilation then
private readonly string _localDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Environment.SetEnvironmentVariable("webdriver.edge.driver", _localDir + "MicrosoftWebDriver.exe");
var driver = new EdgeDriver();
Hope this can help someone.

VS 2013 - Unable to run Coded UI test in Firefox browser

I had version of:
Visual Studio 2013
WebDriver.ChromeDriver.win32 2.2.0
selenium-dotnet-strongnamed-2.35.0
Firefox 24
But when I run Coded UI test I had received the next error:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException:
Failed to start up socket within 45000 ms
or the next error:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: An
error occurred while connecting to Firefox
I folowed instructions of here: Selenium components for Coded UI Cross Browser Testing
Please help to resolve this issue.
Two things: update Selenium to v2.37 (v2.35 doesn't support Firefox 24) and don't use the strong-named assemblies unless you have to.
I mean, really, have to.
They create more problems then they are worth.

Timeout while trying to contact RemoteTestNG in Selenium on Mac

I have a TestNG setup running on Eclipse Indigo 20120216-1857 and TestNG for Eclipse v2.0. Dev environment is Mac OSX 10.8.2. Target is a web server running on Ubuntu 12.04.
Error: 'Couldn't contact the RemoteTestNG client. Make sure you don't have an older version of testng.jar on your class path.'
This error only happens when i'm running selenium scripts. not on my other api oriented test cases. I have selenium-server-standalone-2.25.0.jar running.
This same setup is working on my windows 7 dev environment.
This is a brand new eclipse setup and workspace on the mac.
I had met same question. I hope my resolved method can help you.
Method:
Please open Eclipse->Preferences->Then click TestNG->Restore Defaults
root reason: I had use ReportNG instead of testng default report,but after that I forgot to restore config. So when I make a new project,run as TestNG,but not add ReportNG jars, it report error.

Selenium WebDriver - FirefoxDriver error: Failed to start up socket within 45000

I'm getting this error:
tests.IntegrationTests.Selenium.RegisterAndLogin (TestFixtureSetUp):
SetUp : OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000
when I carry out the following in my code:
using System;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
namespace ekmProspector.tests.IntegrationTests.Selenium
{
[TestFixture]
public class RegisterAndLogin
{
private IWebDriver driver;
[TestFixtureSetUp]
public void Init()
{
driver = new FirefoxDriver();
}
}
Can't get much simpler really, but the error is fatal. Any ideas?
Solution is as easy as pie :)
Right Click on your .Net (C#) Project and select 'Manage NuGet Packages ...' option, as shown below:
Then select Selenium specific packages, they need updated so update them.
The updated packages will be updated automatically.
It works for me.
I got this working in the end, I removed all the package sub-folders which were added by NuGet when installing WebDriver and decided to added these manually. Created a 'lib' folder, then unzipped the selenium binaries into that folder. Then added references to all the binaries. Seems to be fine now.
Versions
FF v48
Selenium Webdriver v2.53.1
Windows 7 (x64)
.Net 4.0 and .Net 4.5
Trying the fixes
As per #jaffa I manually added the following refereces and got the problem:
WebDriver.dll v2.53.1
WebDriver.Support.dll v2.53.1
I then unreferenced them and followed #HassanRahman and used NuGet:
WebDriver.dll v2.53.1
WebDriver.Support.dll v2.53.1
Still same error.
OpenQA.Selenium.WebDriverException : Failed to start up socket within 45000
Troubleshooting
I had a hunch and decided to downgrade from targeting .Net 4.5 to .Net 4.0 (Full not client profile) and the error changed to:
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista
I wondered if this is why people who reinstalled FireFox got it to work again?
Somewhere there has to be a set of Registry Keys or an Environment Variable to find FireFox's ApplicationStartupPath. You can see some of those paths in this ProcessMonitor trace:
In the screenshot above you can see the app (AstrobLabe) I'm using running this line of code:
using (IWebDriver driver = new FirefoxDriver(ffprofile))
It causes a search for FireFox v48 and its looking in the wrong directory:
C:\Program Files (x86)\Mozilla FireFox\FireFox.exe
On my system FireFox is installed in:
C:\Program Files (x86)\Mozilla\Firefox\FireFox.exe
Anyway finding and correcting this issue (Cannot find Firefox binary in PATH or default install locations) is for someone else to fix, I just copied the Firefox directory to Mozilla FireFox.
But then it goes back to the original error:
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055
Solution
Then I came across this answer which says that FireFox v46 works with Selenium 2.53:
Which Firefox version is compatible with Selenium 2.53.0?
When I downgraded I saw that FFv46 installs to:
C:\Program Files (x86)\Mozilla FireFox\FireFox.exe
So check if your FF install is in this location - which based on the ProcessMonitor Trace Selenium cant find:
C:\Program Files (x86)\Mozilla\Firefox\FireFox.exe
I solved this by completely removing firefox and all profiles and reinstalling.
I found that I was able to to fix this problem in Firefox Selenium by updating my Selenium packages in NuGet.
But it still leaves you with the problem of manually updating the Chrome and IE drivers if similar problems arise.
I also faced the problem while running the the test in NUnit. I found many solution to remove or degrade your Firefox.But i solved this in another way i remove all the references related to web drivers and add the upgrade web driver to the Solution.
In my application the webdriver version was 2.24 so i replaced with 2.43 and now my test are running fine.
For anyone finding this question more recently (2015-02-27), there seems to be an open issue with compatibility with Selenium and Firefox 36:
https://code.google.com/p/selenium/issues/detail?id=8399
You can download Firefox 35 here: http://www.filehippo.com/download_firefox/59889/
I had this issue with latest version of both Firefox (42) and Selenium (2.48.2). Uninstalling and re-installing (via Nuget) fixed the issue for me.
I found that running an older version of resharper (9.2) failed to work with the latest nunit and that caused selenium to timeout.
The temporary solution was to disable resharper (Tools -> Options -> Resharper -> Disable), the permanent solution is upgrading resharper.
None of the previous answers clearly state that specific versions of Selenium WebDriver work with specific versions of Firefox. This SO question tells us that the Webdriver/Firefox compatibility matrix is here.
The other thing worth stating is that Firefox tends to update itself more-or-less automatically when new versions become available, depending on settings. Since Webdriver does not update itself automatically, this opens up the possibility that the Webdriver/Firefox compatibility will unexpectedly break and your test scripts will stop running when Firefox updates itself to a version that is not supported by your Webdriver version. I suspect that the answers above that instruct users to re-install Webdriver using Nuget simply pick up the newest Webdriver which works with the newest Firefox that just installed itself on your machine.
To prevent Firefox from upgrading itself, click on the menu button in Firefox (three horizontal bars, upper-right corner), choose "Options", choose "Advanced" on the left menu, choose the "Update" tab at the top and you'll see a set of radio buttons under "Firefox updates". Choose a setting other that "Automatically install updates".
Reinstalling FF browser fixed the issue.
Which version of Selenium IDE you are using? Try downgrading the Firefox version. The release notes of selenium IDE is mentioned in below link.
https://code.google.com/p/selenium/wiki/SeIDEReleaseNotes
Hope this helps.
1) Downgrade your firefox to < 19 because if i remember correctly WebDriver 2.33 support maxim Firefox 19
2)
FirefoxProfile profile = new FirefoxProfile();
profile.Port = 9966;
Global.Driver = new FirefoxDriver(profile);
P.S. I'm using firefox 16 to not have this issue
I have same issue with selenium version 2.37.xx with Firefox browser 42.0
After updating selenium version 2.48.2 issue is fixed
I was working with on C# with WebDriver 2.53/Firefox 46. Tried reinstalling things, manually re-adding etc but downgrading Firefox to 43 fixed it for me.
Updating through "NuGet" is what helped me. Firefox 47 and Selenium Webdriver 2.53 wasn't working. Checking the selenium site, it still shows "2.53" as their latest. Checking "NuGet" though, I saw there was a "2.53.1" version available. Installing that version is what got my Firefox 47 to work again.
Error image
See the error image, I uninstalled completely and re-install version46, things solved.