I know, that such a question is already asked here before, but it is 4 years old and not quite helpful.
So, what i want to do is simple, i want my selenium (running in WPF and .Net 5.0 in c#) so connect to an open browser to control it. The browser is opened manually with the debuggingport 9222 and i can successfull connect to this browser from another browser instance.
i am able to open a NEW Chrome browser with selenium and control it, but i need to also have the ability to connect to an open instance.
and help would be awesome.
PS: i know that selenium is for testing, and normally not used to not be in a controlled test-environment. =)
thank you so much for you help guys.
Type : chrome://version/ in browser you will get executable path of chrome.exe
copy this and close all chrome instance.
**close all chrome instance and **
start chrome as:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=5555
verify chrome is started with port open by going to localhost:5555
Now add remote debugging port as:
var options = new ChromeOptions();
options.debuggerAddress= "127.0.0.1:5555";
var driver = new ChromeDriver(options);
use chrromeoptions to connect to that port from selenium
Related
im looking example how can i start my normal google chrome in webdriver c#?
For now i use :
ChromeDriver driver;
public ChromeDriverService chromeDriverService;
chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("disable-infobars");
chromeOptions.AddExcludedArgument("enable-automation");
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
driver = new ChromeDriver(chromeDriverService,chromeOptions);
But it run my chromedriver.exe installed inside project. Can i just run my simple installed chrome? Without download any chromedriver.exe? It's important for me , because some website check if there is opened chromium with chromedriver.exe.
Is it possible to do that?
If you want not just open it but also perform some interaction with your site then you have to deal with Selenium and WebDriver.
You can try Python and undetected-chromedriver which has some workarounds preventing some systems to detect that your browser is running under webdriver control.
Unfortunately, it's the chromedriver.exe that lets you interact with Chrome so, without the driver, you wouldn't be able to interact with the actual browser.
If your issue is with chromium, try driving Mozilla with GeckoDriver
Selenium always uses chromedriver.exe for interacting with Chrome, I think you mean you want to load your default data directory. You can add a chrome option for this purpose:
chromeOptions.AddArguments(#"C:\Users\<your user name>\AppData\Local\Google\Chrome\User Data")
Take care, any other chrome must not be running that time with the same data directory. Like you may have run for your personal use.
You can also create a data directory somewhere else if you just want to show some realistic behavior to a website. But some websites are smart enough so it does not work every time.
We are doing the Continuous integration using C# selenium for web base application. We have trigger the script from TFS using the test agent. But the build or the execution is getting successful if the browser type is chrome. For the IE bower we are facing the issue. Please help us in resolving this issue.
Note: When we trigger manual execution from server , execution in IE happens successfully.
Below is my Exception screenshot.
enter image description here
Seems it related to the Webdriver.
Just try below things to check if that works for you:
1 .Try the latest IE
2 .Include setting capabilities of the browser when starting it. Try the below settings and see if it works to help it stay focused on the newly opened window.
capabilities = new DesiredCapabilities();
capabilities.setCapability("ignoreProtectedModeSettings", true);
capabilities.setCapability("ie.ensureCleanSession", true);
webDriver = new InternetExplorerDriver(capabilities);
3 .Edit the browser profile and increase timeout to 180 seconds or more from default 60 seconds. Please note that this constructor is available in .Net API only.
For internet explorer driver, you can use below syntax.
driver = new InternetExplorerDriver(#"z:\seleniumc", new InternetExplorerOptions(),TimeSpan.FromMinutes(5));
Refer to Selenium Webdriver for details.
I am struggling through what appear to be issues with WebDriver properly interacting with the Internet Explorer Server (IE11). I have quite a number of tests already authored and working in Chrome but when I try to run the exact same tests using the latest IE Driver server (2.46.0 - downloaded from http://www.seleniumhq.org/download/)
I have read a number of articles on setting up a registry entries and adding my site to the list of trusted sites to to possibly handle a few of these issues but I have been un-successful (Selenium WebDriver on IE11)
Within the page above, one of the responses links to a Microsoft site for downloading IE Web Driver for IE 11 (http://www.microsoft.com/en-us/download/details.aspx?id=44069), this link wants to download and install something.
My question: Is there a difference in the WebDriver from the Selenium site versus the MS site?
Thanks
Sean
Try disabling the native event for IE shown as follows
var options = new InternetExplorerOptions { EnableNativeEvents = false };
options.AddAdditionalCapability("disable-popup-blocking", true);
Driver = new InternetExplorerDriver(options);
Also, DesireCapabilities expands the ability of controlling driver instance more.
I use selenium FirefoxDriver in my tests and I run these tests parallel - in each thread is running separated Firefox instance. Everything works fine when I use normal FireFox, but if I want to run these tests with Firefox portable, the first instance launch successful, but second, third, etc... fails with this error:
Your Firefox profile cannot be loaded. It may be missing or inaccessible.
This is how I launch Firefox from code:
var profile = new FirefoxProfileManager().GetProfile("default");
var firefoxBinary = new FirefoxBinary("Path to FireFoxPortable.exe");
_driver = new FirefoxDriver(firefoxBinary, profile);
Any ideas what I am doing wrong?
Thanks.
The Firefox driver is trying to launch Firefox using a profile that is already in use. This is not possible as a profile can only be used once. The reason why it appears to be working while launching Firefox manually multiple times is because Firefox will reuse the existing running Firefox process with the already loaded profile.
Based on this information the solution to your problem is either 1) have the Firefox driver launch Firefox with unique/new profiles, 2) change your code so that only one instance of the Firefox driver is required.
To launch Firefox with multiple instances, use: firefox.exe -P "My Profile" -no-remote. Do not that the -no-remote parameter should not be used with the first profile launched, which in your case will be the "default" profile. More on this here: http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile.
To launch Firefox Portable with different profiles, if the previous commands are not applicable for Firefox Portable, follow the instructions here: http://portableapps.com/support/firefox_portable#second_profile.
Is there a way to tell WebDriver in C# Selenium tests to open Chrome developer tool console, or some other way to get console to open while running Selenium tests without breaking them?
Or ability to programmatically read output to the console?
So far I have tried opening console manually (CTRL + SHIFT + I) while test is running, but that did break the test every-time.
To open chrome console:
var inSim = new WindowsInput.InputSimulator()
inSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LCONTROL);
inSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LSHIFT);
inSim.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VK_J);
inSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LSHIFT);
inSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LCONTROL);
What you can do: take a snapshot of the browser (including the opened console).
What you cannot do: use the webDriver (it will crash the test, but if you close the console, the same way you opened it, you will be able to continue)
Why: selenium needs an exclusive connection to DevTools.
Notice - some OS have strict input rules and might prevent the inputSimulator from working when the computer is locked or when you are running this code in a machine which has no keyboard connected to it (a server that is handled remotely)
hope this helps...