I currently work with C# with AppWinDriver and Appium for automated tests for WPF, but in the project app that i work, it is detected correctly sometimes, others times work good and some times open the page but doesn't detect the WindowsElements of the app.
Any idea on the root cause of the issue or a solution or workaround?
Code:
AppiumOptions desiredCapabilities = new AppiumOptions();
desiredCapabilities.AddAdditionalCapability("app",app);
desiredCapabilities.AddAdditionalCapability("createSessionTimeout", "60000");
desiredCapabilities.AddAdditionalCapability("newCommandTimeout", "60000");
desiredCapabilities.AddAdditionalCapability("platformName", "Windows");
desiredCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredCapabilities, TimeSpan.FromMinutes(5));
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
Related
I am trying to hide command prompt window when starting selenium chrome, but I can't figure it out.
Here is my code:
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("--headless");
var browser = new ChromeDriver(driverService, chromeOptions);
But it crash on: System.InvalidOperationException: 'session not created: This version of ChromeDriver only supports Chrome version 85
I tried to manually add path to driver but It crash's also.
Different code I used
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("--headless");
chromeOptions.BinaryLocation = "C:\\Users\\TriX\\Downloads\\chromedriver_win32";
var browser = new ChromeDriver(driverService, chromeOptions)
Now it crash on: OpenQA.Selenium.WebDriverException: 'unknown error: Failed to create Chrome process.'
Thanks for help I am completely lost :(
I tried different codes as shown, but without success.
Thanks to #r000bin i managed to resolve the problem. I also find out that I installed outdated version of ChromeDriver. So, I downloaded the correct one and it started to work.
I had old ChromeDrive nuget version
Downloaded the new one and uninstalled old one
Started to work :)
I want to drag and drop an element with selenium. But I noticed that it takes a little bit before he releases after the moveto. Is there a way to speed this up so it will release immediately when the moveto is done?
my current code is:
new TouchAction(_driver)
.LongPress(200, 200).MoveTo(200, 600).Release().Perform();
my driver I setup as following:
var appiumOptions = new AppiumOptions();
_driver = new AndroidDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
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'm using Selenium webdriver 3.3 and ChromeDriver 2.28 (32bit). My slave machine is Windows 7 running Chrome 57.
When Chrome starts I am trying to use ChromeOptions over RemoteWebDriver to disable the "save your password" pop-up using the parameter "password_manager_enabled".
However, it seems to have no effect at all. I have tried many variations around ChromeOptions, JSON strings and simple strings but all to no avail.
ChromeOptions cOpt = new ChromeOptions();
cOpt.addUserProfilePreference("profile.password_manager_enabled", false);
var capabilities = chromeOpts.ToCapabilities() as DesiredCapabilities;
// Add OS, Platform capabilities etc
string gridConnectionURL = "xxxx"
driver = new CustomRemoteDriver(new Uri(gridConnectionURL), capabilities, new TimeSpan(0, 5, 0));
Does anyone know the "correct" way to set this preference so it works?
You just need to replace
//cOpt.AddUserProfilePreference("password_manager_enabled", "false");
cOpt.AddUserProfilePreference("credentials_enable_service", false);
cOpt.AddUserProfilePreference("profile.password_manager_enabled", false);
My original question was unclear I was really looking for a way to start IE with a clean session running on the Grid. I thought the Selenium solution to this was broken, turns out it was how I was using it :facepalm: So I have updated my question to reflect that part.
So my issue is that I cannot get IE to start in a clean session when I run it on Selenium Grid. I have done a fair share of research and implemented the DesiredCapabilities that is supposed to handle this for IE.
internetExplorerCapabilities.SetCapability(ieOptions.EnsureCleanSession.ToString(), true);
But sadly this is not working and I have opened a ticket with the selenium developers if you are interested in tracking it.
Your code ieOptions.EnsureCleanSession.ToString() will return true or false and not ensureCleanSession. To set the capability:
var options = new InternetExplorerOptions();
options.EnsureCleanSession = true;
options.RequireWindowFocus = true;
var capabilities = (DesiredCapabilities)options.ToCapabilities();
capabilities.SetCapability(CapabilityType.Version, "11");
var driver = new RemoteWebDriver(new Uri("http://10.34.161.112:5555/wd/hub"), capabilities);