0

I have gone through the available issues but not being able to identify the problem. Posting here to get help. OS - windows -10 browser - firefox - 107.0.1 selenium java - 4.8.1

testing for firefox - browser is not launching -

Code:

package demo;

import org.openqa.selenium.WebDriver; //import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver;

public class FirstSeleniumTC {

public static void main(String[] args) {
    
    //System.setProperty("webdriver.chrome.driver","C:\\selenium-java\\chromeDriver\\chromedriver.exe");
    //WebDriver driver = new ChromeDriver();
    //driver.get("https://www.facebook.com/");
    
    System.setProperty("webdriver.gecko.driver","C:\\selenium-java\\firefoxDriver\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("https://www.facebook.com/");
    
}

Console Error:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'DESKTOP-QKEHO5U', ip: '192.168.56.1' at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:157) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:130) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:111) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:101) at demo.FirstSeleniumTC.main(FirstSeleniumTC.java:17) Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver process to start. Build info: version: '4.8.1', revision: '8ebccac989' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:218) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:98) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) ... 6 more

For chrome - the browser is launched but the url is not used- showing as - not secure data-

Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 8431 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Mar 22, 2023 6:43:58 PM org.openqa.selenium.remote.http.WebSocket$Listener onError WARNING: Invalid Status code=403 text=Forbidden java.io.IOException: Invalid Status code=403 text=Forbidden at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92) at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118) at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:333) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:454) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833)

Exception in thread "main" org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:54687/devtools/browser/b8f002dc-36c4-48db-8c52-f3943bef0598 Build info: version: '4.8.1', revision: '8ebccac989' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.(NettyWebSocket.java:102) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:128) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:107) at org.openqa.selenium.devtools.Connection.(Connection.java:78) at org.openqa.selenium.chromium.ChromiumDriver.lambda$new$2(ChromiumDriver.java:116) at java.base/java.util.Optional.map(Optional.java:260) at org.openqa.selenium.chromium.ChromiumDriver.(ChromiumDriver.java:114) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:82) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:50) at demo.FirstSeleniumTC.main(FirstSeleniumTC.java:13)

Please help. I am a beginner.

2

2 Answers 2

1

https://www.youtube.com/watch?v=7ZdlSW4S7h4 just add the argument for chrome, it will work. For me firefox issue still exists. ChromeOptions options = new ChromeOptions(); options.addArguments("--remote-allow-origins=*");

Sign up to request clarification or add additional context in comments.

Comments

0

If you still having error, try adding argument options to ChromeDriver method.

ChromeOptions options = new ChromeOptions();
    options.addArguments("--remote-allow-origins=*");
    WebDriver driver = new ChromeDriver(options);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.