Very new to Selenium testing and after reading the doc I tried to setup my own Selenium Grid Hub but I'm failing to use it for my local testing.
I setup the Selenium Grid Hub on a kubernetes cluster (following https://github.com/kubernetes/examples/tree/master/staging/selenium) and I manage to reach my nodes.
I've built a simple java application to test this is working as expected and I manage to reach web based url like http://www.google.com but I would like to be able to test my local app by using my RemoteWebDriver.
Here is what is actually working:
log.info("test selenium");
ChromeOptions chromeOptions = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://my-k8-node.com:32223/wd/hub"), chromeOptions);
driver.get("http://www.google.com");
String pageSource = driver.getPageSource();
log.info(pageSource);
driver.quit();
But I get a This site can't be reached - localhost refused to connect. with
driver.get("http://localhost:8080/health/check");
The same with
driver.get("http://host.docker.internal:8080/health/check");
Or with
driver.get("http://127.0.0.1:8080/health/check");
I didn't find any documentation on how to achieve this kind of setup but any hint is welcome.
I would like to further integrate the selenium testing to my Gitlab CI/CD so I should be able to run the test from a "local" point of view.
Thanks for reading.
Related
I am trying to load a web page with Selenium 3 and chrome driver in a Docker container and I don't see the resources loading in there. Below is how the web page looks when I load it in the docker container. Chromedriver version here is 86
But when I load it from my local machine the web page loads fine with all the resources. Below is how the remote driver is initiated for execution in Docker.
Below is the list of ChromeOptions I use. (Casting here is because of multiple other browser options returned from this same method)
options = new ChromeOptions();
((ChromeOptions) options).setBinary("/opt/google/chrome/google-chrome");
((ChromeOptions) options).setAcceptInsecureCerts(true);
((ChromeOptions) options).addArguments("--no-sandbox", "--disable-dev-shm-usage");
((ChromeOptions) options).addArguments("--disable-extensions");
options.setCapability("browserVersion", "general");
Then instantiating the driver like this.
driver = new RemoteWebDriver(
url,
SeleniumHelper.getCapabilities("chrome",
myGrid.getForwardProxy()));
What am I doing wrong here? Why aren't the resources loading? Any help would be much appreciated.
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.
I have a situation here that we have a webGL dependent application to automate. i have automated the whole application on my laptop, and this application is running fine on chrome on my laptop. but the issue is when i run this application from a seperate machine which is a selenium GRID node. It gives me a message that the application required Webgl and and it ask me to enable the webGL. i have tried different methods like selenium option and ignoring the chrome black list as well.
when i open the browser manually and open the application it runs find and i checked on url chrome://gpu. it shows that the gpu is enaled.
but when i invoke the selenium and run the test cases,. the browser initiates with WebGl as disabled
i found the solution to this. here is the code you can use to enable WebGL for chrome.
DesiredCapabilities capability = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
**options.addArguments("--ignore-gpu-blacklist");**
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability("chrome.binary", "C:\\Temp\\chromedriver.exe");
capability.setVersion("9999");
capability.setCapability(ChromeOptions.CAPABILITY, options);
return new RemoteWebDriver(HUB_URL,capability);
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.
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..