0
FirefoxOptions chromeOptions = new FirefoxOptions();
WebDriver driver = null;

@BeforeTest
public void beforeTest() throws Exception
{
    driver = new RemoteWebDriver(new URL("http://localhost:4444"), chromeOptions);
}

@Test
//Checking the title of iamNeo (Home - iamneo)
public void iamNeo() throws InterruptedException 
{
    // driver.manage().window().maximize();
    driver.navigate().to("http://iamneo.ai/");
    String title = driver.getTitle();
    System.out.println(title);
    Assert.assertEquals(title, "Learning and assessment solution for Universities and Enterprises");
}
@Test
//Moving to FACEBOOK
public void nextPage() throws InterruptedException 
{
    driver.navigate().to("https://www.facebook.com");
    String title = driver.getTitle();
    Assert.assertEquals(title, "Facebook – log in or sign up");

}
@Test
//Back to iamNeo
public void backPage() throws InterruptedException 
{
    driver.navigate().back();
    String title = driver.getTitle();
    System.out.println(title);
    Assert.assertEquals(title, "Learning and assessment solution for Universities and Enterprises");
}
@Test
//Current URL
public void currentURL() throws InterruptedException 
{
    System.out.println(driver.getCurrentUrl());
    String title = driver.getTitle();
    System.out.println(title);
    Assert.assertEquals(title, "Learning and assessment solution for Universities and Enterprises");
    driver.navigate().forward();
    driver.navigate().refresh();
}

@AfterTest
public void afterTest() 
{
    driver.quit();
}
:
It is Throwing Session Not created Exception : 

Could not start a new session. Possible causes are invalid address of the remote server or browser start-up :

org.openqa.selenium.SessionNotCreatedException: 
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'eeeccebaefcebfacecbccfaabacdfdabdafecefecf-0', ip: '10.41.17.6', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.217+', java.version: '11.0.13'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}}]
Capabilities {}
        at ai.iamneo.testing.Testing_Selenium_TestNg.AppTest.beforeTest(AppTest.java:24)
Caused by: java.lang.RuntimeException: NettyHttpHandler request execution error
        at ai.iamneo.testing.Testing_Selenium_TestNg.AppTest.beforeTest(AppTest.java:24)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:4444 after 180000 ms
        at ai.iamneo.testing.Testing_Selenium_TestNg.AppTest.beforeTest(AppTest.java:24)
Caused by: ja
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ai.iamneo.testing</groupId>
    <artifactId>Testing-Selenium-TestNg</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Testing-Selenium-TestNg</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.4.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <compilerVersion>11</compilerVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

It is mentioning BuildFailure while executing
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
Is There an issue with this 3.0.0-M5 Version of this plugin
Dharma176
  • 1
  • 1
  • Can you confirm if you have selenium grid running at the URL mentioned for the RemoteWebDriver? If yes, then change the webdriver initialization to WebDriver driver = new RemoteWebDriver(new URL("https://localhost:4444/wd/hub"), chromeOptions); – Srinivasu Kaki Feb 18 '23 at 17:29
  • What is Selenium client version? What is Selenium Server(Grid) version? where do you run your server jar, what is its IP addr? – Mahsum Akbas Feb 18 '23 at 18:41
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 19 '23 at 10:37
  • I included the pom file please find it helpful if needed – Dharma176 Feb 20 '23 at 02:53
  • I am working in a remote IDE and I am very much restricted what I can access and I included pom for you to see. – Dharma176 Feb 20 '23 at 07:42

1 Answers1

0

Instead of:

new URL("http://localhost:4444")

you need to pass:

new URL("http:///127.0.0.1:4444")

possibly you have to append /wd/hub at the end as:

new URL("http:///127.0.0.1:4444/wd/hub")

References

You can find a relevant detailed discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352