테스트를 작성하기 위해 Appium 및 IntelliJ를 사용하여 테스트를 수행하려는 app komoot가 포함 된 Android Phone 에뮬레이터를 설정했습니다. 나는 맥북 에어에서 일하고있다. 데 후 : 내 안드로이드 에뮬레이터를 시작, Appium 서버를 시작하고 IntelliJ에 내 테스트 (자바에서) 작성, 내 테스트를 실행하고 첨부 된 그림에 표시된 오류가 발생합니다. 나는 또한 내 간단한 테스트 스크립트와 내 테스트 "komootTest"를 실행하여 발생하는 오류 로그 메시지를 복사/붙여 넣기했습니다.IntelliJ (OSX)에서 Android 테스트를 실행하면 java.lang.NullPointerException이 발생합니다.
나는 던져지고있는 과실에 관하여 혼동한다. 44 번째 줄에 나와 있듯이 올바른 id를 가진 komoot (로그인 버튼)의 요소 인 변수를 인스턴스화합니다. 이 경우 왜 null 예외가 발생합니까? 필요에 따라 더 자세한 정보를 제공 할 수 있습니다. 감사합니다. 내가 komootTest.java을 실행할 때
다음
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import java.net.URL;
public class komootTest
{
AppiumDriver driver;
@Before
public void setUp() throws Exception
{
//set desired capabilities and specify device name
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "BigBrother Emulator");
//capabilities.setCapability("appPackage", "de.komoot.android");
//capabilities.setCapability("appActivity", "com.google.android.gms.auth.api.signin.internal.SignInHubActivity");
//establish a connection with the server
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void end() throws Exception
{
//kill connection with server after test has been executed
driver.quit();
}
@Test
public void logInHereButton()
{
//reference UI element by ID and click it
WebElement logInHere = driver.findElement(By.id("de.komoot.android:id/textview_login"));
logInHere.click();
}
}
오류 메시지입니다 : 여기
내 테스트 komootTest.java 코드입니다 : ,[TestNG] Running:
/Users/coracoleman/Library/Caches/IdeaIC2016.1/temp-testng-customsuite.xml
java.lang.NullPointerException
at komootTest.logInHereButton(komootTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:74)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
===============================================
Default Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Process finished with exit code 0
이미지 대신, 질문에 코드를 넣어야합니다. –
코드가 질문의 범위를 벗어났습니다 –
모든 라이브러리/드라이버를 올바르게 설치 했습니까? –