I am using the current opera driver with Selenium for testing of a website (so that we can support Opera as an approved browser for our website). I code in C#.
When I open Opera I get a popup at the top of the screen that states:
You are using an unsupported command-line flag: --enable-blink-features=ShadowDOMV0. Stability and security will suffer.
I currently setup my Opera instance with the following code:
string operaExeLocation = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + #"\AppData\Local\Programs\Opera\74.0.3911.107\opera.exe";
OperaDriverService service = OperaDriverService.CreateDefaultService(#"C:\Opera\", "operadriver.exe");
var operaOptions = new OperaOptions
{
BinaryLocation = operaExeLocation,
LeaveBrowserRunning = false
};
driver = new OperaDriver(service, operaOptions);
I suspect that the unsupported flag can be turned off in the operaOptions - but I haven't found any documentation on how to do that. Please help if you are familiar with setting up the driver.
Related
I'm using the Selenium 3.14 Webdriver to test a site with Firefox. (I test other browsers also - but this problem is with Firefox).
For some tests I want to enable popup blocking. My Firefox instantiation is:
driver = new FirefoxDriver(geckodriverDirectory);
driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(1.0d);
I tried adding an option, as follows:
var options = new FirefoxOptions();
options.SetPreference("disable-popup-blocking", false);
driver = new FirefoxDriver(driverDir, options);
driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(1.0d);
But that failed to enable popup blocking. Any ideas for setting the correct Firefox option?
I finally solved this by setting the following preference instead of the preference shown above:
options.SetPreference("dom.disable_open_during_load", true);
The true value seems counter intuitive - because the impact is to have popup blocking enabled - but it works.
It would be great if Firefox would publish a list of preferences that their webdriver recognizes.
I have a requirement to switch from chrome to edge driver chromium
I am having issues trying to launch the browser as a different user. We need to open the browser with different users who have different roles and validate
To manually do this you would right click edge browser > shift and click Microsoft edge > Run as different user
I am using the following NuGet Packages:
MicrosoftEdge.SeleniumTools 3.141.2
Selenium.Webdriver 3.141.0
Microsoft Edge version
91.0.864.54
Previously with using chrome and the package Selenium.Chrome.Webdriver i was able to use the following
service.StartupDomain = ""
service.StartupUserName = ""
service.StartupPassword = ""
service.StartupLoadUserProfile = true;
However with MicrosoftEdge.SeleniumTools 3.141.2 i am unable to find a similar solutions. Does anyone know an equivalent solution?
Current code below
EdgeDriverService service = EdgeDriverService.CreateChromiumService(driverpath, msedgedriverExe);
var edgeOptions = new EdgeOptions();
edgeOptions.UseChromium = true;
service. ???
edgeOptions. ???
IWebDriver driver = new EdgeDriver(service, options)
Sorry didn't find a similar question and maybe somebody can help.
Due to additional requirements we have to test our project not only with Chrome but with Firefox as well. When we simply changed a test context to Firefox it turned out that all calls of findElement took 10 times more time than with Chrome. All tests are completely ruined. We tried to use different test machines but the results are the same. The project is on Core .Net. For testing we use MSTest V2, Firefox 63 (64 bit) and Geckodriver 0.22 (64 bit) .
Very appreciate any help.
By referring to the previous answer, my issue was solved by below code.
string geckoDriverDirectory = "Path of geckodriver.exe"
FirefoxDriverService geckoService =
FirefoxDriverService.CreateDefaultService(geckoDriverDirectory);
geckoService.Host = "::1";
var firefoxOptions = new FirefoxOptions();
firefoxOptions.AcceptInsecureCertificates = true;
Driver = new FirefoxDriver(geckoService, firefoxOptions);
Yep. You’re definitely hitting the performance issue that is part of .NET Core. It doesn’t happen on Chrome, IE, or Edge, because the driver executables for each of those browsers (unlike geckodriver) listen on both the IPv4 and IPv6 loopback addresses. If you were to specify “::1” as the host for geckodriver with .NET, the problem would disappear.
Refer to https://github.com/SeleniumHQ/selenium/issues/6597
A complete .Net Core webdriver for Firefox 7/14/2020:
// .Net Core workaround #1: Slow Firefox webdriver
string projectFolder = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
string geckoDriverDirectory = projectFolder + "\\netcoreapp3.1\\";
FirefoxDriverService geckoService =
FirefoxDriverService.CreateDefaultService(geckoDriverDirectory);
geckoService.Host = "::1";
var ffOptions = new FirefoxOptions();
ffOptions.BrowserExecutableLocation = #"C:\Program Files\Mozilla Firefox\Firefox.exe";
ffOptions.AcceptInsecureCertificates = true;
// This profile will by-pass *ALL* credentials. Note that Chrome uses Internet Explorer settings, so it does not need this.
// You must pre-setup the profile, by launching Firefox and doing phone authentication
// The profile's location is: C:\Users\<windows logon>\AppData\Local\Mozilla\Firefox\Profiles
// Without this, if your AUT uses SSO, you will always get prompted for the PIN or Two factor authentication
FirefoxProfile profile = new FirefoxProfileManager().GetProfile("Selenium");
ffOptions.Profile = profile;
// DotNet Core workaround #2- Code page
// https://stackoverflow.com/questions/56802715/firefoxwebdriver-no-data-is-available-for-encoding-437
// https://stackoverflow.com/questions/50858209/system-notsupportedexception-no-data-is-available-for-encoding-1252
CodePagesEncodingProvider.Instance.GetEncoding(437);
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
_driver = new FirefoxDriver(geckoService, ffOptions);
In case anyone is trying gary.zhang's answer in Javascript, it looks like this:
let driver = new Builder()
.forBrowser('firefox')
.setFirefoxService(new firefox.ServiceBuilder('path_to_driver', host='::1'))
.setFirefoxOptions(new firefox.Options().headless())
.build();
Took me a bit of staring at it to figure out how to convert the syntax.
My source code is copied from selenium docs site. I didn’t make any change.
http://docs.seleniumhq.org/docs/03_webdriver.jsp#user-input-filling-in-forms
I installed Selenium library via NuGet, including
Selenium Remote Control(RC), Selenium WebDriver Mono, Selenium WebDriver Support Classes, Selenium WebDriver, and Selenium WebDriver-backed Selenium.
When I run this code, a new Firefox window was opened. But the Firefox doesn’t navigate to the URL, it just stuck, nothing was loaded.
I tried the Firefox v27, v29, v30 and v31, none of them worked.
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
// Requires reference to WebDriver.Support.dll
using OpenQA.Selenium.Support.UI;
class GoogleSuggest
{
static void Main(string[] args)
{
// Create a new instance of the Firefox driver.
// Notice that the remainder of the code relies on the interface,
// not the implementation.
// Further note that other drivers (InternetExplorerDriver,
// ChromeDriver, etc.) will require further configuration
// before this example will work. See the wiki pages for the
// individual drivers at http://code.google.com/p/selenium/wiki
// for further information.
IWebDriver driver = new FirefoxDriver();
//Notice navigation is slightly different than the Java version
//This is because 'get' is a keyword in C#
driver.Navigate().GoToUrl("http://www.google.com/");
// Find the text input element by its name
IWebElement query = driver.FindElement(By.Name("q"));
// Enter something to search for
query.SendKeys("Cheese");
// Now submit the form. WebDriver will find the form for us from the element
query.Submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
// Should see: "Cheese - Google Search"
System.Console.WriteLine("Page title is: " + driver.Title);
//Close the browser
driver.Quit();
}
}
I have had the same problem. the solution is simply uninstall your current firefox browser and download older version "i tried 2010 version 3.6.10 works great". your code is fine the problem is Mozilla people have decided to not give the right to any third party application to control Firefox.
good luck
I created a console application (with target: .Net Framework 4) and added the next references:
Selenium.WebDriverBackedSelenium.dll
ThoughtWorks.Selenium.Core.dll
WebDriver.dll
WebDriver.Support.dll
static IWebDriver driver = null;
if (driver == null)
{
ChromeOptions options = new ChromeOptions();
options.AddArguments("--start-maximized");
driver = new ChromeDriver(#"C:\selenium\net40", options);
// it opened a new window (about:blank)
}
driver.Navigate().GoToUrl("http://www.facebook.com");
but nothing is happen.
I use: ChromeDriver 26.0.1383.0
and my chrome browser version is: 29.0.1547.62 m
this is the command line:
Started ChromeDriver
port=1866
version=26.0.1383.0
log=C:\Users\salon\Desktop\Application Alon\ConsoleApplication1\ConsoleApplicati
on1\bin\Debug\chromedriver.log
[156:4144:0828/233852:ERROR:platform_thread_win.cc(127)] NOT IMPLEMENTED
[5804:5712:0828/233856:ERROR:textfield.h(173)] NOT IMPLEMENTED
I have windows 7 if it's needed..
any help appreciated!
For the later versions of Chrome (27+), there is a new shiny ChromeDriver:
http://code.google.com/p/chromedriver/downloads/list
Note the section within the summary on the page...
ChromeDriver server for win32 (v2.2.215849.dyu) supports Chrome v27-30
Also, you should remove the Thoughtworks & WebDriverBackedSelenium references, they are not required and you don't seem to be using them.