I'm using Selenium RC + .Net Client Driver. I've created a Firefox profile in my c:\selenium\ directory. Here's my code:
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*custom C:/Program Files/Mozilla Firefox/firefox.exe -profile c:/selenium/", "http://www.google.com/")
When I run this, I get the following error:
Failed to start new browser session: Error while launching browser
What is the proper way to do this?
You need to launch it via RC rather than in your code.
So you would do
java -jar selenium-server.jar -firefoxProfileTemplate c:\selenium\
to launch the browser and then do
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/")
and that should launch Firefox for with the profile you want.
In Java you can create the Selenium Server programmatically and pass a File as the newFirefoxProfileTemplate configuration property:
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setPort(5499);
rcc.setFirefoxProfileTemplate(newFirefoxProfileTemplate); // This is a File object
SeleniumServer server = new SeleniumServer(rcc);
server.start();
Perhaps there are similar (or the same) vb.net classes available.
Related
When I create a firefox driver with a firefox driver service this is logged to the console: 1564067211938 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\minec\\AppData\\Local\\Temp\\rust_mozprofile.wCNOb94oHRE2" The problem is the console when this happens gets effectively separated from my program and doesn't close when I close it with the stop button in visual studio. I also can't log anything to the console after that.
Is there any way to disable it?
Here is my code:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(geckoDriverPath.Replace(#"\geckodriver.exe", ""), "geckodriver.exe");
var driver = new FirefoxDriver(service);
I figured out how to remove all logs except fatal error logs.
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(geckoDriverPath.Replace(#"\geckodriver.exe", ""), "geckodriver.exe");
var options = new FirefoxOptions();
options.LogLevel = FirefoxDriverLogLevel.Fatal;
var driver = new FirefoxDriver(service, options);
Try adding System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "target" + File.separator + "browser.log");
before the browser is being initialized
ie. before
var driver = new FirefoxDriver(service);
I am using below mentioned code to initialize a firefox driver with service, options and timeout.
var Service = FirefoxDriverService.CreateDefaultService(RunConfig.DriverPath);
Service.HideCommandPromptWindow = RunConfig.HideDriverCommandPromptWindow;
var Options = new FirefoxOptions();
if (!string.IsNullOrWhiteSpace(RunConfig.PathToBrowserBinary))
Options.BrowserExecutableLocation = RunConfig.PathToBrowserBinary;
Options.Profile = new FirefoxProfile();
Options.Profile.SetPreference(Preference.Name,PathToDownloadFolder));
Options.Profile.SetPreference(Preference.Name, Preference.Value);
return new FirefoxDriver(Service, Options, TimeSpan.FromSeconds(90));
But it gives me an error that The path is not of legal for while initializing firefox profile
Solved it. The problem was the seleniumwebdriver dll I was using is present in some other project. Adding the selenium webdriver and support dll to the current project worked.
IDE: Visual Studio 2015
Geckodriver.exe (Version 0.19.0) - Published: 9/25/2017
Firefox version: 56.0b8 (64-bit)
Selenium webdriver version: 3.6.0
Using Selenium and C # I did as lines of code below:
using (FirefoxDriver = new FirefoxDriver () driver)
{
driver.Navigate (). GoToUrl("https://www.teste.gov.br/seguro/loginPortal.asp");
Thread.Sleep (1000 * 60);
}
The page opens a message of "Your connection is not private", error "Your connection is not secure".
To resolve this issue you have already used the following codes:
profile = webdriver.FirefoxProfile ()
profile.accept_untrusted_certs = True
driver = new FirefoxDriver (profile)
profile = webdriver.FirefoxProfile ()
profile.accept_untrusted_certs = True
driver = new FirefoxDriver (profile)
profile.setAcceptUntrustedCertificates (true);
profile.setAssumeUntrustedCertificateIssuer (false);
driver = new FirefoxDriver (profile)
ffProfile.setAcceptUntrustedCertificates (true)
ffProfile.setAssumeUntrustedCertificateIssuer (false)
driver = new FirefoxDriver (ffProfile)
and other codes ...
But the problem continues. How to solve this problem?
TL:DR; There is no reasonable approach to solving this problem.
If it's absolutely necessary to visit the site only, e.g. to create a cookie, use PhantomJS. Every browser driver I've tried gives the error, and it's impossible to bypass without some sort of security exploit.
The browser is literally letting you know the site is insecure. Albeit its a government site, it might be compromised.
On a separate note, its probably cleaner to do this:
FirefoxDriver() ffDriver = new FirefoxDriver();
ffDriver.Navigate("myCoolSite.url");
Developed a WPF application in C# using selenium web driver. Given the IEdrive path as follows and it works fine.
driver = new InternetExplorerDriver(#"E:\AG\myGateway\myGateway_FF\driver");
But when I given the path like below
driver = new InternetExplorerDriver(#"http:\10.200.0.86\drivers");
then the following error throws out.
The file http:\10.200.0.86\drivers\IEDriverServer.exe does not exist.
Because I need to publish the WPF in my localhost. Please help me out.
For this, I have followed the below steps.
1.Created a new directory in the client system.
private static string _localpath = #"D:\Gateway\Drivers\";
System.IO.Directory.CreateDirectory(_localpath);
2.Then separately downloaded the driver and stored in the local path under directory which was created in the first step.
private static string _IEdriverpath = "http://10.200.0.86/Drivers/IEDriverServer.exe";
private static string _localpathIE = #"D:\Gateway\Drivers\IEDriverServer.exe";
wc.DownloadFile(_IEdriverpath, _localpathIE);
3.Finally executed the selenium command
driver = new InternetExplorerDriver(_localpath);
I'm try to use selenium-server-standalone-2.33.0.jar with opera and need to change some profile preferences.
It possible to create OperaProfile object in C# project and using it like this:
OperaProfile profile = new OperaProfile(); // Error: Type or namespace 'OperaProfile' could not be found
profile.preferences().set("User Prefs", "Ignore Unrequested Popups", false);
DesiredCapabilities capabilities = DesiredCapabilities.Opera();
capabilities.SetCapability("opera.profile", profile);
IWebDriver driver = new RemoteWebDriver(new Uri("http://host:4444/wd/hub"), capabilities);
In this case I got error message
Type or namespace 'OperaProfile' could not be found
Assuming you are on Windows:
The Operadriver is written in Java and not suported directly in C#, as it is mainatined not by the Selenium project team but by Opera.
To use it, you have to run the standalone Selenium webserver (from console on windows) before starting the test. get it here
you need to set the OPERA_PATH to point to your opera.exe file. Start the server with the command:
java -jar selenium-server-standalone-2.33.0.jar
i use a small bat for these two tasks:
SET OPERA_PATH="C:\Progra~2\Opera\opera.exe"
cd C:\pathToSeleniumJarFile
C:\Progra~2\Java\jre7\bin\java.exe -jar selenium-server-standalone-2.33.0.jar
C#:
testing with remotewebdriver object in your C# code to connect to it.
switch (WebBrowser)
{
case Browser.Chrome:
// chromedriver.exe has to be in the debug folder
ChromeOptions chrome = new ChromeOptions();
chrome.AddArguments("--ignore-certificate-errors");
webDriver = new ChromeDriver(chrome);
break;
...
case Browser.Opera:
//note: set OPERA_PATH environment variable (in cmd or global)
DesiredCapabilities opera = DesiredCapabilities.Opera();
opera.SetCapability("opera.profile", #"C:\OperaProfile");
webDriver = new RemoteWebDriver(opera);
break;
default:
throw new NotImplementedException();
if you want to manipulate the profile of the opera client (e.g. to accept untrusted certificates etc) you need to set
opera.SetCapability("opera.profile", #"C:\OperaProfile");
Copy an existing Profile to a location of your choice, here C:\OperaProfile.
==> Avoid spaces in all the pathes <==