appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.2k stars 753 forks source link

Unable to create Appium 2.0 Session Using AppiumDriverLocalService. #2018

Closed JYOTIPRAKASH225 closed 11 months ago

JYOTIPRAKASH225 commented 11 months ago

Description

While creating Appium2.0 Session Programatically using AppiumDriverLocalService Getting NullPointerException

Environment

Details

While creating Appium2.0 Session Programatically using AppiumDriverLocalService Getting NullPointerException

java.lang.NullPointerException at java.base/java.io.FileOutputStream.(FileOutputStream.java:226) at java.base/java.io.FileOutputStream.(FileOutputStream.java:184) at org.openqa.selenium.remote.service.DriverService$Builder.getLogOutput(DriverService.java:448) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:495) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:89) at com.appium.appium2Session.getDriver(appium2Session.java:42) at com.appium.appium2Session.main(appium2Session.java:29)

Code To Reproduce Issue [ Good To Have ]

    service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().withIPAddress("127.0.0.1")
            .usingPort(port).withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
            .withArgument(GeneralServerFlag.LOG_LEVEL, "debug"));
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("platformName", "iOS");
    capabilities.setCapability("appium:platformVersion", "15");
    capabilities.setCapability("appium:deviceName", "jyotipraksh's iPhone");
    capabilities.setCapability("appium:automationName", "XCUITest");
    capabilities.setCapability("appium:app", bundleID);
    capabilities.setCapability("appium:udid", "6279765bfc1744548bec50ddc00780049a3f155c");
    capabilities.setCapability("appium:includeSafariInWebviews", true);
    capabilities.setCapability("appium:newCommandTimeout", 3600);
    capabilities.setCapability("appium:connectHardwareKeyboard", true);

    System.out.println("Appium context set to application :" + appName);
    driver = new IOSDriver(service, capabilities);

Exception Stacktraces

(https://gist.github.com/JYOTIPRAKASH225/57d639519e62744800df3ef68300b915)

Link To Appium Logs

java.lang.NullPointerException at java.base/java.io.FileOutputStream.(FileOutputStream.java:226) at java.base/java.io.FileOutputStream.(FileOutputStream.java:184) at org.openqa.selenium.remote.service.DriverService$Builder.getLogOutput(DriverService.java:448) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:495) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:89) at com.appium.appium2Session.getDriver(appium2Session.java:42) at com.appium.appium2Session.main(appium2Session.java:29)

ashwithpoojary98 commented 11 months ago

2014

Please refer to this bug. The issue with the log file.

Refer below code new AppiumServiceBuilder() .usingAnyFreePort() .usingDriverExecutable(new File("/usr/local/bin/node")) .withLogFile(new File(System.getProperty("user.dir")+"appium.log")) .withArgument(GeneralServerFlag.RELAXED_SECURITY) .build() .start();

valfirst commented 11 months ago

Duplicate of #2004