The browser opens but the debugger hangs. If I comment out the AddArgument line then it proceeds fine. Any ideas?
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--user-data-dir=C:\\Users\\Ian\\AppData\\Local\\Google\\Chrome\\User Data");
IWebDriver driver = new ChromeDriver("C:\\Users\\Ian\\Desktop", chromeOptions);
It seems to want all other Chrome windows closed to work with existing user data.
Related
Good day to all! I have a problem using Selenium ChromeDriver in console application, i use code like this:
var options = new ChromeOptions();
options.AddArgument("--headless");
options.AddArgument("--no-sandbox");
options.AddArgument(#"user-data-dir=G:\Data\ProfilesData\Profile1");
var driverService = ChromeDriverService.CreateDefaultService(Directory.GetCurrentDirectory());
driverService.HideCommandPromptWindow = true;
WebDriver driver = new ChromeDriver(driverService, options);
driver.Navigate().GoToUrl(URL);
Please help me understand so that the browser goes to the desired URL in the console application
I tried to remove the --headless parameter, the browser starts and goes to the desired page, this process does not work without visualization
I found a problem in using the profile, when commenting out the line with connecting the profile everything works, I found a comment on one of the sites that says about a Chrome bug, it cannot work with a profile in headless mode. But everything works fine on my local machine, it doesn't work on the server machine. It is necessary to look for some settings of the server machine.
This is my code with open web.whatsapp.com url and I add argument "Headless" so not open page but give the selection of the which browser to open.
So how to avoid browser selection and get page.
but without "Headless" then easy to open webpage and not asking any option to selection
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
var options = new ChromeOptions();
options.AddArgument("headless");
Driver = new ChromeDriver(service, options);
Driver.Navigate().GoToUrl("https://web.whatsapp.com/");
What worked for me was adding a double-dash before the argument.
chromeOptions.AddArgument("--headless");
I am running chromedriver on windows server 2016 with IIS, i have my test project installed and invoking it with an MVC5 API. That all seems fine but chromedriver and chrome.exe only seems to open as a background processes.
The same code opens these fine locally, i am not using any of the driver flags for headless browsing either. if i return the drive page source i can see that chromedriver went to google and returned the correct html in my API.
It just does not work for normal / non headless tests with google or our application.
var driver = x.StartWebDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("http://www.google.com");
return driver.PageSource;
Any ideas?
I have got the same issue and this is how I solve this:
Open a command prompt and navigate to your ChromeDriver location.
Execute chromedriver.exe and you will see the message as below.
image here
In the image above you see chrome driver is listening on port 9515.
Now change your code as below, rebuild and call you api to execute your test.
ChromeOptions options = new ChromeOptions();
//set your chromeoptions here
Uri uri = new Uri("http://localhost:**9515");
_driver = new RemoteWebDriver(uri, options);
Open the chrome driver and note the port number(eg:5353)
In java:
System.setProperty(chromeDriverName, chromeDriverLocation);
ChromeOptions options = new ChromeOptions();
URL uri = new URL(chromeDriverPort);//http://localhost:5353
WebDriver driver = new RemoteWebDriver(uri, options);
your problem gets solved in is server.
When I create a new chrome driver in Selenium while Google Chrome is already running AND I am referencing the users settings/data (via user-data-dir). A new Chrome window will open, but my application will hang. The ChromeDriver console will display the following error each second: DevTools Request: 127.0.0.1:12585/json/version. DevTools request failed
Screenshot:
Code to instantiate the driver:
ChromeDriverService driverService = ChromeDriverService.CreateDefaultService();
//driverService.HideCommandPromptWindow = true;
driverService.EnableVerboseLogging = true;
string path = Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%\\Google\\Chrome\\User Data");
ChromeOptions options = new ChromeOptions();
options.AddArguments("user-data-dir=" + path);
options.AddArguments("--start-maximized");
options.AddArguments("--disable-extensions");
IWebDriver driver = new ChromeDriver(driverService, options);
This will work perfectly fine in every instance if I do not try and load user settings/data. If I am trying to load user setting/data it will only work if there is no instance of Chrome running on the device already.
Versions:
Selenium v 2.47.0
ChromeDriver v 2.16.333243
Chrome v44.0.2403
What can I do to resolve this?
If anyone was looking for answer like me;
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2443
This behavior is by design. Two instances of Chrome can't use the same user-data-dir at the same time. Otherwise they would try to update the same set of files and cause corruptions. So if an instance is already running, attempting to start another instance using the same user-data-dir will cause the second instance to ask the first instance to open a new window, and then the second instance exits.
I want to use Selenium Web Driver in VS 2010 C# to open a Chrome browser, navigate to some web page and then close the driver but keep the browser open. I realize that I will have to manually close the browser afterwards and I'm okay with that.
So far I have:
DriverService service = ChromeDriverService.CreateDefaultService();
ChromeOptions options = new ChromeOptions();
options.AddAdditionalCapability("chrome.detach",true);
m_driver = new ChromeDriver(service, options, TimeSpan.FromMilliseconds(1000));
[m_driver does stuff like navigate page, double click stuff, etc]
[last line: try to close driver but not browser]
I have tried all the following as the last line
m_driver.Dispose(); // closes both browser and driver
m_driver.Close(); //closes just the browser and not the driver
m_driver.Quit(); // closes both browser and driver
service.Dispose(); // closes both browser and driver
Any ideas?
We can detach chrome instance from chromedriver using "detach" options.
Sample Code:
ChromeDriverService cdservice = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("/path/to/chromedriver.exe"))
.withLogFile(new File("/path/to/chromedriver.log"))
.usingAnyFreePort().withVerbose(true).build();
cdservice.start();
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("detach", true);
ChromeDriver driver = new ChromeDriver(cdservice,options);
driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
driver.get("http://www.google.com/");
// Do not call driver.quit().. instead stop chromedriver service.
cdservice.stop();
This is simply not possible, that kind of separation does not exist.
chromeservice.driver.close()
has worked for me in the past but in this case you may need to write some coding for a method.
It is posible a least in c# you need the next lines:
driverOptions.AddExcludedArgument("enable-automation");
driverOptions.AddAdditionalCapability("useAutomationExtension", false);
(Python) When I called the selenium .get() function, Chrome would open up and close shortly after. I found online the advice to use the following code to remedy this issue: It worked for me in Python3; MacOSX 12.3 Monterey; Chrome Version 105.0.5195.102
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(chrome_options=options, executable_path='/Users/<user_acct_name>/.wdm/drivers/chromedriver/mac64/105.0.5195/chromedriver')