Since geckodriver v0.16.0 flashplayer is disabled by default.
Is there any possibility to start firefox with enabled flashplayer?
I'm using C#. My code right now:
var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("selenium"); //created firefox user named selenium
profile.SetPreference("plugin.state.flash", 1);
Code bellow doesn't work for me:
profile.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", true);
When I use this one:
profile.SetPreference("plugin.state.flash", 1);
firefox is asking if I want to enable flashplayer, and than refreshes page (with all inputs filled previously - so i got empty fields).
If I select "allow and remember", next time I start this code nothig is saved. I'm getting the same situation.
I found solution there:
How to enable Adobe Flash in FireFox Selenium webdriver with FirefoxProfile
If I replaced profile.setPreference("plugin.state.flash", 1); to profile.setPreference("plugin.state.flash", 2); it stopped to asking me if I want to enable flash player.
Here is the solution for you:
With Selenium 4.3.0, gecko driver v0.16.0 & Mozilla Firefox 53.0 this code works well with myfreecams.com.
It is worth mentioning that the default Firefox profile is not very automation friendly. When you want to run automation reliably on a Firefox browser it is advisable to make a separate profile. Automation profile should be light to load and have special proxy and other settings to run good test. You should be consistent with the profile you use on all development and test execution machines. If you used different profiles everywhere, the SSL certificates you accepted or the plug-ins you installed would be different and that would make the tests behave differently on the machines.
So, Create a New Firefox profile and use the same in the Test script involves three steps process. First you need to Start the Profile Manager, second is to Create a New Profile and third is to use the same profile in Test scripts. Let's assume we created a new FirefoxProfile by the name "debanjan".
Use the following code to open http://www.myfreecams.com/ with your new FirefoxProfile "debanjan":
String driverPath = "C:\\Utility\\BrowserDrivers\\";
//Mozila Firefox
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile("debanjan");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, testprofile);
FirefoxDriver driver = new FirefoxDriver(dc);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.navigate().to("http://www.myfreecams.com/");
PS: This code is in Java so you may have to convert it into C# format.
Let me know, if this helps you.
Related
im looking example how can i start my normal google chrome in webdriver c#?
For now i use :
ChromeDriver driver;
public ChromeDriverService chromeDriverService;
chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("disable-infobars");
chromeOptions.AddExcludedArgument("enable-automation");
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
driver = new ChromeDriver(chromeDriverService,chromeOptions);
But it run my chromedriver.exe installed inside project. Can i just run my simple installed chrome? Without download any chromedriver.exe? It's important for me , because some website check if there is opened chromium with chromedriver.exe.
Is it possible to do that?
If you want not just open it but also perform some interaction with your site then you have to deal with Selenium and WebDriver.
You can try Python and undetected-chromedriver which has some workarounds preventing some systems to detect that your browser is running under webdriver control.
Unfortunately, it's the chromedriver.exe that lets you interact with Chrome so, without the driver, you wouldn't be able to interact with the actual browser.
If your issue is with chromium, try driving Mozilla with GeckoDriver
Selenium always uses chromedriver.exe for interacting with Chrome, I think you mean you want to load your default data directory. You can add a chrome option for this purpose:
chromeOptions.AddArguments(#"C:\Users\<your user name>\AppData\Local\Google\Chrome\User Data")
Take care, any other chrome must not be running that time with the same data directory. Like you may have run for your personal use.
You can also create a data directory somewhere else if you just want to show some realistic behavior to a website. But some websites are smart enough so it does not work every time.
Hello (first time posting here),
I am having trouble getting geckodriver to bypass certificate errors. I've done a lot of research and made sure that I have the latest versions of all components. Reason I stress that is because a lot of the past questions that exist on this site discuss obsolete methods such as using DesiredCapabilities.
This is my code:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
FirefoxProfile profile = new FirefoxProfile("QA"){
AcceptUntrustedCertificates = true
};
FirefoxOptions options = new FirefoxOptions(){
Profile = profile
};
var driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://google.ca");
The code above fails and I still get certificate errors on Firefox. One thing I noticed when debugging it is that the driver still sees the capability "acceptInsecureCerts" as "false". Screenshot below.
Am I doing something wrong? Please advise.
I am currently using:
Selenium V3.9 (latest)
Mozilla Firefox Nightly 60.0a (latest)
geckodriver 19.1 (latest)
Aah! Found it: Firefox Options has an "addcapabilities" function that fixes it.
options.AddAdditionalCapability("acceptInsecureCerts", true, true);
I am struggling through what appear to be issues with WebDriver properly interacting with the Internet Explorer Server (IE11). I have quite a number of tests already authored and working in Chrome but when I try to run the exact same tests using the latest IE Driver server (2.46.0 - downloaded from http://www.seleniumhq.org/download/)
I have read a number of articles on setting up a registry entries and adding my site to the list of trusted sites to to possibly handle a few of these issues but I have been un-successful (Selenium WebDriver on IE11)
Within the page above, one of the responses links to a Microsoft site for downloading IE Web Driver for IE 11 (http://www.microsoft.com/en-us/download/details.aspx?id=44069), this link wants to download and install something.
My question: Is there a difference in the WebDriver from the Selenium site versus the MS site?
Thanks
Sean
Try disabling the native event for IE shown as follows
var options = new InternetExplorerOptions { EnableNativeEvents = false };
options.AddAdditionalCapability("disable-popup-blocking", true);
Driver = new InternetExplorerDriver(options);
Also, DesireCapabilities expands the ability of controlling driver instance more.
I use selenium FirefoxDriver in my tests and I run these tests parallel - in each thread is running separated Firefox instance. Everything works fine when I use normal FireFox, but if I want to run these tests with Firefox portable, the first instance launch successful, but second, third, etc... fails with this error:
Your Firefox profile cannot be loaded. It may be missing or inaccessible.
This is how I launch Firefox from code:
var profile = new FirefoxProfileManager().GetProfile("default");
var firefoxBinary = new FirefoxBinary("Path to FireFoxPortable.exe");
_driver = new FirefoxDriver(firefoxBinary, profile);
Any ideas what I am doing wrong?
Thanks.
The Firefox driver is trying to launch Firefox using a profile that is already in use. This is not possible as a profile can only be used once. The reason why it appears to be working while launching Firefox manually multiple times is because Firefox will reuse the existing running Firefox process with the already loaded profile.
Based on this information the solution to your problem is either 1) have the Firefox driver launch Firefox with unique/new profiles, 2) change your code so that only one instance of the Firefox driver is required.
To launch Firefox with multiple instances, use: firefox.exe -P "My Profile" -no-remote. Do not that the -no-remote parameter should not be used with the first profile launched, which in your case will be the "default" profile. More on this here: http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile.
To launch Firefox Portable with different profiles, if the previous commands are not applicable for Firefox Portable, follow the instructions here: http://portableapps.com/support/firefox_portable#second_profile.
I am using selenium WD in C# for cross browser testing but facing a strange problem that when ever i run my test using Nunit firstly Firefox window will open & then my desired browser window will open & run the test on it(desired browser).
As per my knowledge if any system is not having Firefox installed in it then it fails the script.
So is there any way to change this default value of browser in selenium.
I am able to run tests on different browser, my problem is only that before opening my desired browser by default first system is opening firefox. which create issue for me & my tests.
public void SetupTest()
{
driver = new SafariDriver();
baseURL = "http://google.com/";
verificationErrors = new StringBuilder();
}
Most probably, somewhere in your code you are initializing the Firefox Driver. Search for this within you code:
new FirefoxDriver();
You could also debug to the line
driver = new SafariDriver();
and see if it has an assigned value already.
But I am also pretty certain that you are initializing a FirefoxDriver somewhere.