Again timeout creating new FirefoxDriver with Firefox 43 and above - c#

With latest Selenium WebDriver v 2.50.00 I am getting (again) following exception:
Failed to start up socket within 45000 ms. Attempted to connect to the
following addresses: 127.0.0.1:7055
executing:
driver = new FirefoxDriver(new FirefoxBinary(), firefoxProfile, pageLoadTimeout);
This happens with version 43 and higher of Firefox. I have downgraded Firefox to v. 39 and there it works OK.
It seems that this issue happened before couple of times with various versions of Selenium and Firefox, see here or here.
Any workaround for this or downgrading Firefox and waiting for a new version of Selenium WebDriver is the only way?

Yes, It is bug which still going to resolve for latest versions
You need set the Preferences as xpinstall.signatures.required", false.
Below code is working for me but it is in java. you get the idea where you need to change
WebDriver driver = null;
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.manage().window().maximize();
driver.get("https://www.google.co.in/");
Hope it will help you :)

Related

C# Selenium Chromedriver only shows 'data'

I created a very simple C# project to test Selenium and Chrome Driver, but when I run it, it gets stuck at the very first line, ie. creating ChromeDriver object.
I have set up as following:
.NET Core 3.1 console app (also tried .NET 4.7)
Installed Selenium.WebDriver 3.141.0 and Selenium.WebDriver.ChromeDriver 87.0.4280.8800.
My Chrome version is "Version 87.0.4280.88 (Official Build) (64-bit)". I have double-checked compatibility with Chrome and ChromeDriver.
Code:
using OpenQA.Selenium.Chrome;
namespace MyFirstSelenium
{
class Program
{
static void Main(string[] args)
{
ChromeDriver chrome = new ChromeDriver();
chrome.Navigate().GoToUrl("https://www.google.co.jp/");
}
}
}
visual studio screen
chromedriver.exe is copied to the debug folder as expected, so I assume the problem is neither compatibility nor path.
chromedriver
When I run the code, the result is an empty window with 'data' in the address bar. No error is thrown. I have searched for several hours and found some articles, but most of them are old and none of these answers led to success.
Any help is appreciated. Thank you.
Added chromedriver.exe verbose console output.
#Piotr M.
chromedriver console
logfile
https://drive.google.com/file/d/1ECOS8E55aaTFV63e8P-7n6uRVcf49PRN/view?usp=sharing
New code
Works when I first execute "chromedriver.exe --verbose --log-path=chromedriver.log", but without it, it throws WebDriverException.
OpenQA.Selenium.WebDriverException: 'A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL localhost:9515/session. The status of the exception was UnknownError, and the message was: No connection could be made because the target machine actively refused it. No connection could be made because the target machine actively refused it.'
var chromeOptions = new ChromeOptions();
chromeOptions.BrowserVersion = "87";
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:9515"), chromeOptions);
Possibly a classic case of cyclic redundancy.
chrome is a reserved word, you may have to change the variable name to something else e.g. chromex. So your effective line of code will be:
ChromeDriver chromex = new ChromeDriver();
Additional Consideration
Consider the following aspects aswell:
Instead of using the ChromeDriver class use the IWebDriver interface.
IWebDriver driver = new ChromeDriver();
Instead of the partial url google.co.jp/ you need to pass the complete url through GoToUrl() as follows:
driver.Navigate().GoToUrl(#"https://www.google.co.jp/");

C# Google Chrome Selenium URL Navigation with BinaryLocation

Greetings StackOverflow Community,
My issue is simple. I have the following five lines of code, that I can't figure out why Google Chrome doesn't launch google.com when using a custom binary location.
var Chrome = new ChromeOptions();
Chrome.AddArgument("no-sandbox");
Chrome.BinaryLocation = #"C:\GoogleChrome\chrome.exe";
ChromeDriver driver = new ChromeDriver(#"C:\ChromeDriver", Chrome);
driver.Navigate().GoToUrl("https://www.google.com");
Any ideas? All I get is the default chromedriver URL of "data:," when Google Chrome launches.
Why isn't the driver.navigate command working when using a Chrome.BinaryLocation? If I comment out that line, than it works fine.
I am using the following:
Windows 7
Visual Studio Community Edition 2017
Google Chrome version 67
chromedriver 2.41
.NET 4.5 Bindings
hey i dont think you need of binary location
And maybe Chrome is already a type,
try this:
ChromeOptions options = new ChromeOptions();
options.AddArgument("no-sandbox");
var driver = new ChromeDriver(#"C:\GoogleChrome", options);
driver.Navigate().GoToUrl("https://www.google.com");
Okay, I found the answer to this question. I don't know why the Portable version of either Firefox, Chrome or other Chromium based browsers do not function this way, but I resolved this issue by copying the enterprise installation files from program files for Chrome to another directory on the computer and then pointing the Selenium script to use that binary location. Then it worked just fine.
It was also useful to point Chrome to a custom chrome profile location to keep more of the Chrome application from using the local users's AppData folder.
If anyone is interested in accomplishing the same task, I can provide some example code that accomplishes this task. Just message me for more details.

How to launch Firefox with default profile using selenium 3.13.1 and C#

I am new to Selenium and after exhaustive research I can't find a reliable example to launch Firefox with my default profile so I retain my extensions, bookmarks etc. Much has changed and the examples I find are now deprecated or use Java syntax. Here's my set up:
Visual Studio 2017 Community
C# - Selenium WebDriver 3.13.1
Selenium WebDriver Support
geckodriver - Firefox v. 61.0.1
References have been set on the solution. Here is my code:
FirefoxProfileManager myProfile = new FirefoxProfileManager();
FirefoxProfile profile = myProfile.GetProfile("C:\\Users\\Robert\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\4halwx5j.default");
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
IWebDriver driver = new FirefoxDriver(options);
driver.Url = "https://lastpass.com/?ac=1&lpnorefresh=1";
driver.Manage().Window.Maximize();
Would anyone be so kind to provide an example that works using WebDriver 3.13.1 FF v. 61.0.1and C# syntax?

Chrome extension not being added to Chrome browser when using ChromeDriver for Selenium

I am attempting to open Chrome browser with an extension. Chrome opens, but it doesn't have my extension. Here is my code. Please let me know what I am doing wrong.
private IWebDriver GetChromeDriver(BrowserConfigurationOptions browserConfigOptions)
{
var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var chromeDriverPath = Path.GetFullPath(outPutDirectory + #"\Drivers");
var options = new ChromeOptions();
options.AddExtension(outPutDirectory + #"\3.1.5_0.crx");
options.AddArguments("disable-infobars");
options.AddUserProfilePreference("credentials_enable_service", false);
if (browserConfigOptions.KioskModeForChrome)
options.AddArgument("--kiosk");
return new ChromeDriver(chromeDriverPath, options);
}
The extension exists in the path where I expect it to be.
Chrome version: 60
ChromeDriver v:2.29
Selenium v: 3.5.2
The issue is that WebDriver 3.5.2 does not support ChromeDriver 2.29. These problems can be resolved if we downgrade to WebDriver 3.4. Then everything works. I logged an issue on their Github but I believe that backwards compatibility is not expected between WebDriver and older versions of ChromeDriver.

Failed to start up socket within 45000

I'm using FF version 19
it was all working fine till yesterday and suddenly today morning i start getting this error and i have the same exact code that was running before, no change nothing
error message:
Test 'M:.TestCases.12' failed: Failed to start up socket within 45000
OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.ConnectToBrowser(Int64 timeToWaitInMilliSeconds)
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start()
at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient()
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile)
at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxProfile profile)
0 passed, 1 failed, 0 skipped, took 145.80 seconds (Ad hoc).
here is my source code:
public static IWebDriver GetDriver()
{
switch (Common.BrowserSelected)
{
case "ff":
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", url);
drv = new FirefoxDriver(profile);
break;
case "ie":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
drv = new InternetExplorerDriver(options);
break;
case "chrome":
//_driver = new ChromeDriver();
break;
}
return drv;
}
Firefox 19 'support' was added in Selenium's latest versions. So since you are using .NET, the direct download for the latest at the time of this post is version 2.31.2:
selenium-release.storage.googleapis.com/index.html
I have this issue with Firefox 43 and Selenium 2.48.
It happens when your Selenium driver server is running in a 32 bit process and you start the 64 bit version of Firefox.
The cause is that the webdriver server tries to connect to port 7055 which should be opened by the webdriver that runs in the Firefox executable. But you can see in TcpView from www.sysinternals.com that Firefox does not open this port. So the driver waits until his timeout (45 seconds) elapses.
This happens even after turning off the Windows Firewall completely.
All posts that I found in internet do NOT help: Upgrade Selenium, downgrade Firefox, etc..
But after installing the 32 bit version of the same Firefox 43 it works. I see in TcpView how Firefox 32 bit opens the port correctly:
In my code I use
FirefoxProfile Prof = new FirefoxProfile();
FirefoxBinary Bin = new FirefoxBinary(sBrowserExe);
mDriver = new FirefoxDriver(Bin, Prof);
With sBrowserExe = "C:\Program Files\Mozilla Firefox 43\firefox.exe"
the 64 bit version of Firefox 43 is started and I get the timeout exception.
With sBrowserExe = "C:\Program Files (x86)\Mozilla Firefox 43\firefox.exe"
the 32 bit version of Firefox 43 is started and it works!
UPDATE: The developers from Firefox now broke Selenium support COMPLETELY. New Firefox versions from 48 upwards need a digital signature for all extensions to be installed.
https://wiki.mozilla.org/Addons/Extension_Signing
What I don't understand is why Selenium people cannot get a signature for the current Selenium driver??
Firefox version 47.0 has a bug that does not allow to use it with Selenium. This bug has been fixed in version 47.0.1.
Firefox versions from 48.0 and above do not install the old Selenium driver anymore. They must be automated with Marionette (= Gecko) driver.
The problem is that Marionette is still beta and has a lot of missing features so there is currently no solution to automate the new Firefox versions.
As you see here the new driver is full of bugs: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver/status
If Upgrading Webdriver doesn't help you can downgrade FireFox that will solve 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.
Install all the updates in your Nuget package manager. Restart IDE.
Downgrading firefox version is not recommended for testing. But last but one version downgrade sounds good.
This solution worked for me.

Categories

Resources