I want to open IE in Private mode to run the set of test cases. The browser is not opening. It shows error as
The HTTP request to the remote WebDriver server for URL {URL} timed out after 60 seconds
Sample code:
InternetExplorerOptions options = new InternetExplorerOptions()
{
ForceCreateProcessApi = true,
BrowserCommandLineArguments = "-private",
};
IWebDriver driver = new InternetExplorerDriver("C:\\Reports", options);
driver.Navigate().GoToUrl("https://www.google.com");
Also I have changed the TabProcGrowth as 0 in Registry Editor.
How to open IE in private mode to run the test case? Anything I want to update in my code. Thanks in advance.
This is how I manage to launch it:
Set the TabProcGrowth as 0 in Registry Editor.
Get the Selenium.WebDriver.IEDriver64 nugget instead of the normal 32 and build the project
Get the IEDriverServer64.exe from bin\Debug\netcoreapp3.1 (the output folder where this file is generated depends on your TargetFramework: .netcore or .netstandard)
Rename that file into IEDriverServer.exe and put it somewhere in a folder
Create the driver instance using the path to that folder. In my case, I created a folder in the project and pointed there
Project: Solution Explorer View
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System.IO;
namespace InternetExplorerPrivate
{
public class Tests
{
public IWebDriver driver;
[SetUp]
public void Setup()
{
InternetExplorerOptions options = new InternetExplorerOptions();
options.ForceCreateProcessApi = true;
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.BrowserCommandLineArguments = "-private";
driver = new InternetExplorerDriver(Path.GetFullPath(#"..\..\..\IEDriver"), options);
}
[Test]
public void Test1()
{
driver.Navigate().GoToUrl("https://stackoverflow.com/");
}
}
}
Related
1- Developer mode active
2- WinApp installed properly
3- Nuget appium dependency installed
4- Microsoft visual studio 2022
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
namespace WebAppDriverNUNIT
{
public class Tests
{
public const string DriverUrl = "http://127.0.0.1:4723/";
//private const string CalculatorAppId ="Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";
[SetUp]
public void Setup()
{
System.Diagnostics.Process.Start(#"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
AppiumOptions Options = new AppiumOptions();
// Options.AdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); // for Universal Windows Platform apps
Options.AddAdditionalCapability("app", "C:\\Windows\\System32\\notepad.exe");
Options.AddAdditionalCapability("deviceName", "WindowsPC");
Options.SetLoggingPreference(OpenQA.Selenium.LogType.Server, OpenQA.Selenium.LogLevel.All);
var driver = new WindowsDriver<WindowsElement>(new Uri(DriverUrl), Options);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
Assert.IsNotNull(driver);
Thread.Sleep(2000);
driver.CloseApp();
}
[Test]
public void Test1()
{
Assert.Pass();
}
}
}
Downgrade (Selenium.WebDriver and Selenium.Support) nuget packages to 3.141.0....your issue will be resolved.
For now, WinAppDriver is not supported by Selenium 4 due WinAppDriver is not yet W3C compliant.
#pawansinghncr You should install Selenium Pre 4.0 (e.g. version 3.4) for all Selenium libraries. Also, set up an appropriate appium nuget.
Greetings stackoverflow community,
I am trying to compile and run the programcode from this website:
https://social.msdn.microsoft.com/Forums/en-US/7bdafd2a-be91-4f4f-a33d-6bea2f889e09/c-sample-for-automating-ms-edge-chromium-browser-using-edge-web-driver
I followed all the instructions listed in the link and set my paths were I wanted them.
The program and the edge driver starts running, but then an error appears.
"An error exeption "System.InvalidOperationException" appeared in WebDriver.dll.
Further Inforamtion: session not created: No matching capabilities found (SessionNotCreated)"
This is the code from my program, more or less copied from the link above:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var anaheimService = ChromeDriverService.CreateDefaultService(#"C:\edgedriver_win64", "msedgedriver.exe");
// user need to pass the driver path here....
var anaheimOptions = new ChromeOptions
{
// user need to pass the location of new edge app here....
BinaryLocation = #"
C: \Program Files(x86)\Microsoft\Edge\Application\msedge.exe "
};
IWebDriver driver = new ChromeDriver(anaheimService, anaheimOptions); -- error appears at this line
driver.Navigate().GoToUrl("https: //google.com/");
Console.WriteLine(driver.Title.ToString());
driver.Close();
}
}
}
I would really appreciate your help!
Best Regards
Max
The article you refer to is a bit out of date. Now we don't need to use ChromeDriver to automate Edge. You can refer to the official doc about how to use WebDriver to automate Microsoft Edge.
I recommend using Selenium 4. Here I install Selenium 4.1.0 NuGet package and the sample C# code is like below:
using System;
using OpenQA.Selenium.Edge;
namespace WebDriverTest
{
class Program
{
static void Main(string[] args)
{
var options = new EdgeOptions();
options.BinaryLocation = #"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
var driver = new EdgeDriver(#"C:\edgedriver_win64", options);
driver.Navigate().GoToUrl("https://www.google.com");
Console.WriteLine(driver.Title.ToString());
driver.Close();
}
}
}
I am trying to connect to profile, its successfully connect to custom firefox profile, but the problem after that is command FirefoxDriver driver = new FirefoxDriver(options); no more works, works only if i remove options then no custom profile.
the before last line returns error OpenQA.Selenium.WebDriverException: 'Process unexpectedly closed with status 0' or The HTTP request to the remote WebDriver timed out after 60 seconds, it only works if I remove options inside FirefoxDriver: FirefoxDriver driver = new FirefoxDriver(options);
Also, doing options.AddArgument("-profile" + "C:\Users\Chill\AppData\Roaming\Mozilla\Firefox\Profiles\5k2mdm2k.myprofile"); instead of spliting the 2 arguments does not launch firefox in the right profile.
Or even options.AddArgument("no-sandbox") or options.AddArgument("-no-sandbox") or options.AddArgument("--no-sandbox") doesn't works, also --profile instead of -profile does not open the right profile also, here is my code anyway:
using System;
using OpenQA.Selenium; // nuget package name: Selenium.WebDriver
using OpenQA.Selenium.Firefox; // nuget package name: Selenium.WebDriver.GeckoDriver
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
FirefoxOptions options = new FirefoxOptions();
options.AddArgument("-profile");
options.AddArgument(#"C:\Users\Chill\AppData\Roaming\Mozilla\Firefox\Profiles\5k2mdm2k.myprofile"); /* type about:profiles in firefox bar to create and manage firefox profiles, from there you will see which profile used, make sure to not use the default one and use root directory */
FirefoxDriver driver = new FirefoxDriver(options); /* code stops here and puts error after closing browser or waiting until it close itself after 60 sec */
driver.Navigate().GoToUrl("https://www.google.com/"); /* can only reach this part of code if i remove turn FirefoxDriver(options); to FirefoxDriver(); on the line upper, but no more custom profile so */
}
}
}
Hope you can help im blocked on this step for 3 days
Using these nugget versions:
<PackageReference Include="Selenium.Firefox.WebDriver" Version="0.27.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.0.0-beta4" />
This works for me:
using OpenQA.Selenium.Firefox;
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var options = new FirefoxOptions();
var profile = new FirefoxProfile(#"C:\Users\CatalinR\AppData\Roaming\Mozilla\Firefox\Profiles\f9n067l1.default");
options.Profile = profile;
var driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://www.google.com/");
}
}
}
I am a beginner in Selenium WebDriver, and I have a problem with poping out notification on Facebook page while I'm trying to log in. I searched a lot, but i did not find anyhing usefull. I found code in java, convert into C# but it didn't work.(I hope that a did it properly) I tried something like this, but nothing. Please, help with this if you can.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, object> hash = new Dictionary<string, object>();
hash.Add("profile.default_content_setting_values.notifications", 2);
ChromeOptions op = new ChromeOptions();
op.AddAdditionalCapability("hash",hash);
IWebDriver driver = new ChromeDriver("path to googlewebdriver");
driver.Url = "http://facebook.com";
driver.Manage().Window.Maximize();
driver.FindElement(By.Id("email")).SendKeys("my email");
driver.FindElement(By.Id("pass")).SendKeys("mypassw" + Keys.Enter);
driver.FindElement(By.XPath("//*[#id='content_container']")).Click();
}
}
}
If you simply want to disable "all" notification on chrome browser, you can use switch --disable-notifications
Code in C# to launch chrome with this switch:
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions"); // to disable extension
options.AddArguments("--disable-notifications"); // to disable notification
options.AddArguments("--disable-application-cache"); // to disable cache
driver = new ChromeDriver(options);
Here's list of switches available for chrome browser: Chromium Comamnd Line Switches
Alternatively, you have options to handle alert by using this code statement:
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Dismiss;
You have other options available here to accept, dismiss, ignore etc.
To disable the annoying "some-annoying-website wants to: 🔔 Show notifications", set your ChromeOptions like this:
ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("profile.default_content_setting_values.notifications", 2);
And pass it to your ChromeDriver:
using (var chrome = new ChromeDriver(options)) ...
ChromeOptions op = new ChromeOptions();
op.AddArguments("--disable-notifications");
Most importantly need to check the versions of Chrome Driver. Some versions it may not support.
I'm trying to publish a web application with below code which uses Microsoft.Build.Evaluation libraries. However below execution fails for a project with error message mentioning to enable NuGet restore. The provided link in error message is not valid since it shows how to enable NuGet restore in Visual Studio IDE.
Please let me know how to enable NuGet when programmatically publishing a web app with Microsoft.Build.Evaluation.
Build FAILED.
C:\x\Dnn.Platform-development\DNN Platform\DotNetNuke.Web\DotNetNuke.Web.csproj(419,5): error : This project references NuGet package(s) that are missing on this computer.Enable NuGet Package Restore to download them.For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\..\..\Evoq.Content\\.nuget\NuGet.targets.
0 Warning(s)
1 Error(s)
The source code used to publish the web application:
using B = Microsoft.Build.Evaluation;
using Microsoft.Build.Logging;
using Microsoft.Build.Framework;
using System.IO;
using System.Collections.Generic;
namespace WebPublisherTest
{
class Program
{
static private readonly string RootTempFolder = #"C:\TST";
static private readonly string PublishDropFolderName = "PublishDrop";
static private readonly string ToolVersion = "12.0";
static void Main(string[] args)
{
string projectFilePath = #"C:\x\Dnn.Platform-development\DNN Platform\Admin Modules\Dnn.Modules.Console\Dnn.Modules.Console.csproj";
string tempLocation = Path.Combine(RootTempFolder, Path.GetRandomFileName());
string publishDrop = Path.Combine(tempLocation, PublishDropFolderName);
var globalProperty = new Dictionary<string, string>
{
{ "Configuration", "Debug" },
{ "OutputPath", publishDrop },
{ "WebPublishMethod", "FileSystem" }
};
ConsoleLogger logger = new ConsoleLogger(verbosity: LoggerVerbosity.Normal);
B.Project p = new B.Project(projectFilePath, globalProperty, ToolVersion);
p.Build(new List<ILogger>() { logger });
}
}
}