I am running a headless firefox browser with Selenium. If I run it in GUI mode then it works fine but when I run it in headless mode then I get an error about element being obstructed.
I really need a way to connect the Firefox remote debugger so I can see what is happening in the headless browser.
How do I enable remote debugging in selenium headless browser?
You can debug marionette Gecko Driver by enabling trace logs and change the log level in order to get trace logs:
You can use FirefoxOptions in Selenium Java client to change the log level
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.TRACE);
WebDriver driver = new FirefoxDriver(options);
For more information have a look at Firefox Source docs. More reading about debugging is here
Related
I have installed the following versions to use selenium with chrome. The chrome browser is getting launched and opens the required url but immediately gets terminated and the window closes within few secs.
Please guide me on any changes I need to do.
Versions:
Chrome:78.0.3904.108
Chrome Driver:78.0.3904.105
Selenium:selenium-java-3.141.59
Java:jdk-8u231-windows-x64
Code:
System.setProperty("webdriver.chrome.driver","C:\\Users\\Pooja\\Desktop\\ChromeDriver\\chromedriver.exe);
WebDriver driver = new ChromeDriver();
driver.get("https://selenium.dev");
System.out.println(driver.getTitle());
driver.quit();
Output in console after execution:
Starting ChromeDriver 78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904#{#877}) on port 1226
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1574867082.995][WARNING]: Timed out connecting to Chrome, retrying...
Nov 27, 2019 10:04:45 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
SeleniumHQ Browser Automation
I tried this using the same versions of Google chrome and the Chrome driver and it works for me. The issue is that you missed a quotation mark at then end of your driver path.
Hope this helps
System.setProperty("webdriver.chrome.driver","C:\\Users\\edgar\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://selenium.dev");
System.out.println(driver.getTitle());
driver.quit();
Error in opening new driver window:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
server log:
Forwarding newSession on session null to remote
I am running following code on linux:
driver= new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), capability);
My hub-node already up and running. Then why i am getting this error.
This error message...
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
and the server log...
Forwarding newSession on session null to remote
...implies that the Selenium Grid Hub / Selenium Grid Node wasn't properly initiated/started. As a result a null session was forwarded to the RemoteWebDriver.
Some more information regarding the versions of the binaries which you have used interms of Selenium server/client, WebDriver variant /version and WebBrowser variant /version and the commands you have used to initiate the Selenium Grid Hub / Selenium Grid Node would have helped us to debug your issue in a easier way.
However this issue can happen due to multiple factors as follows:
You are using the uri 5555/wd/hub, so ensure that Selenium Grid Hub is initiated on port 5555.
You may opt to replace the capability argument with an instance of Options class as follows:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browser", "chrome");
//seting the required capabilities
ChromeOptions options = new ChromeOptions();
options.merge(caps);
WebDriver driver = new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), options);
You can find a relevant discussion in Remote WebDriver UnreachableBrowserException: Could not start a new session
This issue is frequently observed with GeckoDriver/Selenium/Mozilla due to version mismatch of the binaries you are using. As a thumb rule always follow the configuration matrix from the GeckoDriver, Selenium and Firefox Browser compatibility chart
You can find a relevant discussion in WebDriverException: Message: newSession with GeckoDriver Firefox v65 and Selenium through Python 3.7
I'm able to use:
let browserLog = await browser.manage().logs().get('browser');
console.log(util.inspect(browserLog))
in chrome but, does not work for IE and Edge browsers.
Any suggestions?
You cannot. The only browser and driver that currently provides the console log is Chrome w/ Chromedriver. It may be added to the W3C Webdriver spec at a later date, follow this issue https://github.com/w3c/webdriver/issues/406
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 am automating a chromium application using selenium webdriver. These are my configuration settings:
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--url=application url");
chromeOptions.setBinary("application exe file");
chromeOptions.addArguments("--ignore-certificate-errors");
chromeOptions.addArguments("--remote-debugging-port=8000"); WebDriver
driver = new ChromeDriver(chromeOptions);
This code launches the chromium application successfully. I've confirmed that port 8000 is listening and able to get chromium application object on chrome browser.
But I am getting the exception below:
Starting ChromeDriver 2.16.333243
(0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 18739 Only local
connections are allowed. FAILED CONFIGURATION: #BeforeMethod setUp
org.openqa.selenium.WebDriverException: chrome not reachable