5

I am new at Java Test Automation. I receive below message when I run my test. What is wrong it? Thanks by now.

Message: org.openqa.selenium.remote.DesiredCapabilities chrome

INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome() Starting ChromeDriver 2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90) on port 33954 Only local connections are allowed.

Java File
import org.junit.Test;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class TestCase {
    @Test
    public void doTestCase(){
        System.setProperty("webdriver.chrome.driver","D:\\Drivers\\Chrome Driver\\chromedriver\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("start-maximized");
        ChromeDriver driver = new ChromeDriver(options);
        driver.get("https://www.google.com/");
    }
}

Maven File
<?xml version="1.0" encoding="UTF-8"?>
<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>com.alkan.testautomation</groupId>
    <artifactId>JavaTestAutomaiton</artifactId>
    <version>1.0-SNAPSHOT</version>
<dependencies>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>2.44.0</version>
    </dependency>
</dependencies>
</project>
Community
  • 1
  • 1
Alkan Ulutas
  • 51
  • 1
  • 1
  • 3
  • It is just a warning? Are your tests affected? If you are looking for a workaround, see https://stackoverflow.com/questions/47863579/desiredcapabilities-is-obsolete, https://stackoverflow.com/questions/46786043/chromedrivercapabilities-capabilities-is-deprecated, https://stackoverflow.com/questions/46786043/chromedrivercapabilities-capabilities-is-deprecated. – Mate Mrše Dec 14 '18 at 10:10

2 Answers2

3

The INFO you are gettings as the message is because you might have used DesiredCapabilities. Because, if you use ChromeOptions, you should not get the INFO. See what DesiredCapabilities.class contains:

public static DesiredCapabilities chrome() {
    LOG.info("Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`");
    return new DesiredCapabilities("chrome", "", Platform.ANY);
}

The use of the DesiredCapabilities class is supported by Python, Ruby, etc. While it is also available in Java, its usage in Java is deprecated.

Instead, we can use the ChromeOptions class. This is supported by Java, Python, etc.

Ref.: https://chromedriver.chromium.org/capabilities

0

You need to change as follows-

ChromeOptions cap = new ChromeOptions(); 
cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,
                  UnexpectedAlertBehaviour.IGNORE);

driver = new RemoteWebDriver(new URL("http://hub:4444/wd/hub"),cap);

It will fix the issue and you will not encounter that log while executing

yash
  • 1,187
  • 1
  • 19
  • 31
Sobhit Sharma
  • 354
  • 4
  • 27