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)
Related
It appears that the version of Selenium included with Atata does not support the EdgeOption "UseChromium", and when I try to use the Edge Driver, the test run fails unless I rename the driver in the bin\Debug\netcoreapp2.1\drivers\edge\91.0.864.41 folder from "msedgedriver.exe" to "MicrosoftWebDriver.exe", which leads me to believe it's trying to run the old non-chromium Edge - is there some way to get this working?
In order to use Chromium Edge with Atata:
Update Selenium.WebDriver package to 4.0.0-beta2 version.
Change Atata configuration to:
AtataContext.GlobalConfiguration
.UseDriver(() =>
{
EdgeOptions options = new EdgeOptions
{
UseChromium = true
};
// Headless options:
//options.AddArguments("headless", "disable-gpu", "window-size=1024,768");
return new EdgeDriver(options);
})
Atata Samples / Using Headless Edge sample might also help.
For an automation project I have to use selenium webdriver with edge. Unfortunately the site is under IE kernel. So I start edge in IE mode everything works fine. But when the controller needs to detect a new window with windowHandle, it does not detect anything new even with a wait.
Is it possible to make the switch work in IE mode ?
PS: As I use an IE driver I can by changing a few lines start IE. When I run IE the window change is done. When I run Edge with the options I don't detect anything. So everything works fine with the IE browser, the problem only comes from edge and the IE mod.
I am using an IE driver with capabilities like this :
var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver);
var ieOptions = new InternetExplorerOptions{};
ieOptions.AddAdditionalCapability("ie.edgechromium", true);
ieOptions.AddAdditionalCapability("ie.edgepath", "{path to msedge.exe}");
var webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(30));
driver.FindElement(By.Id("button")).Click();
Thread.Sleep(2000);
string popupHandle = string.Empty;
ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
foreach (string handle in windowHandles)
{
if (handle != existingWindowHandle)
{
popupHandle = handle;
break;
}
}
driver.SwitchTo().Window(popupHandle);
Now it is solved. You can download latest Selenium version 4.0 and start scripting for Edge in IE Mode. You can also follow the issue ticket in github in the following link MS Edge in IE Mode
Problem
Getting blank edge page with address as data while setting up UI automation solution with below stack.
Stack
Trying to create a UI Automation - with Selemium VS 2019, Edge Chromium version: 87.0.664.47
Microsoft.Edge.SeleniumTools:3.141.2
Selenium.WebDriver: 3.141.0 - which is compatible with Microsoft.Edge.SeleniumTools.
EdgeOptions op = new EdgeOptions();
//op.UseChromium = true;
string location = #"C:\drivers\";
EdgeDriver d = new EdgeDriver(location, op);
d.Navigate().GoToUrl("https://www.google.com/");
d.Manage().Window.Maximize();
Blank edge page with data:
This line can be modified:
d.Navigate().GoToUrl("https://www.google.com/");
Take out the Navigate() so it is just
d.Url = #"https://www.google.com";
Also not sure why you have commented out d.UseChromium = true; as that is required in order to use Chromium edge. Otherwise it will load the legacy browser.
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.
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.