How to run Selenium script in particular profile/existing browser - selenium

I am trying to open Internet Explorer in same port.
I tried this in chrome using debugger address
ChromeOptions option = new ChromeOptions();
option.setExperimentalOption("debuggerAddress","localhost:9000");
WebDriver driver = new ChromeDriver(option);
Its work on chrome and Edge but not in firefox and Internet Explorer is there any other way to open in same existing browser.
Please help me out here....

Related

Why is Selenium webdriver is not opening webpage?

Hi i am trying to connect to remote webdriver on browserstack using Selenium but whenever the page loads in Chrome and Firefox i get a security message (see images below).
my URL is starting with https:// (when i manually open the browser i have to accept the certificates and continue before the webpage loads)
i have added this line to my code but it does not seem to make any difference:
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, "true");
capability.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
NOTE: This issue only occurs then the tests are run on the GoCD pipeline. when running on intellij it all works fine
error:
org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=nssFailure2&u=https%3A//transport....
in chrome i see this:
and in firefox i get a similar message:
Can you try adding something as below and test:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("ignore-certificate-errors");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
options.addArguments("--test-type");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("disable-gpu");
chromeOptions.AddArguments("window-size=1980,1080");
Driver = new ChromeDriver(chromeOptions);
i have found the problem for anyones future reference.
This is because DNS requests were not forwarded for our host name on GocD.

How can we place the cursor in Chrome Driver address bar and perform Key.Enter events using selenium Web driver using java?

I am automating the application using selenium which is enabled with SSO(VIDM) integration which will take my system domain name and password. The moment I hit the application URL, It will process the SSO(VIDM) and displaying the browser pop up with SSL certificate , OK button. I am unable to locate "OK" button as inspect is blocked for that pop up.
Manual Work Around noticed: Able to select that certificate from the pop up with out clicking okay button by placing the cursor in Chrome driver address bar and then perform enter using the system keyboard.Please see the image here
Add the below chromedriver option to launch specific profile.
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
ChromeDriver driver = new ChromeDriver(options);
Refer to chromedriver page for more information.
ChromeDriver Capabilities

How do you start selenium using Chrome driver and all existing browser cookies?

From what I understand so far, Chrome Driver always starts without any stored browser cookies.
I need the driver start with all the cookies stored by Chrome.
I wonder if there is any way to start the driver with the cookies that are already stored? I'm using C# with .net 4.5.
Yes we can do it by invoking saved chrome profile just like firefox profile. below are steps i noted when i am doing bit back ago
in Java, we can do it by using ChromeOptions and Chrome Profile. In chrome navigate to chrome://version/ It will display profile path and Executable path.
As per my working on this, The profile path is \Local\Google\Chrome\User Data\Profile 3 This is displaying what is displayed when i navigate to chrome://version/ in normal chrome browser. In this profile, i navigated to stackoverflow and saved credentials. So used below code
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("binary", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver", "E:\\selenium_setups\\poi-3.12\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("user-data-dir=C:\\Users\\murali\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 3");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
//WebDriver driver = new ChromeDriver(options);
driver.get("http://stackoverflow.com/");
As per my understanding, i excepted stackoverflow.com page displayed as logged in. but for first time, i am not logged in. so cross checked with chrome://version/ in chrome opened by driver, profile path is displayed as
\Local\Google\Chrome\User Data\Profile 3\Default . then logged manually in that profile it self, which is opened by webdriver and executed gain by closing it.
Finally, page is displayed as logged in. So it may be in java, i hope it will helps you to try in C# .

browser not opening in client side using selenium web driver

I want to open Chrome on the client side using selenium webdriver. I have a piece of code and it works fine for single system, but I can't access it in another system.
I am using selenium-server-standalone-2.44.0.jar, chromedriver for the purpose.
This is the code I use to open browser:
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver=new ChromeDriver();
Is the ChromeDriver on the other system in the same place as on the single system?
Try something like the following (in java):
String currentDir = System.getProperty("user.dir");
String chromeDriverLocation = currentDir + "/../tools/chromedriver/chromedriver.exe";
System.setProperty("webdriver.chrome.driver", chromeDriverLocation);
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("disable-plugins");
options.addArguments("disable-extensions");
WebDriver chrome = new ChromeDriver(options);
chrome.get("http://www.google.com");
Selenium webdriver can be used in different languages.
I can give you an example.
A web application is developed by using python in back-end and front-end is built up with html and a interpreted programming language like javascript. If we use selenium webdriver with python then browser opens at server side. and if we use selenium with javascript then browser opens at client side.

Proxy configuration in Internet Explorer using selenium webdriver

I want to set some proxy setting in internet explorer with the help of webdriver.
Currently I am using this code :
System.setProperty("webdriver.ie.driver", "Path to IEDriverServer.exe");
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("proxyhost:port");
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
capability.setCapability(CapabilityType.PROXY, proxy);
driver=new InternetExplorerDriver(capability);
But it does nothing except giving this message on console :
org.openqa.selenium.browserlaunchers.WindowsProxyManager backupRegistrySettings
INFO: Backing up registry settings...
I have done the settings related to zone and all which are necessary for using IEDriver.
I am able to use Internet explorer through webdriver without using Proxy configuration.
I am using IE9 on Windows 7 with IEDriver.exe version 2.28.0.
Can somebody suggest me some work around for this.Any help is much appreciated.
Possible workaround : Set the PAC file manually in IE. Simply launch the IEdriver. The bad part is is you would keep switching it if u use IE for surfing..