Я настроил эмулятор телефона Android, который содержит приложение komoot, которое я пытаюсь выполнить при использовании Appium и IntelliJ, чтобы написать тест. Я работаю над потоком macbook. После того, как я запустил свой эмулятор Android, запустил сервер Appium и написал свой тест (в java) в IntelliJ, я запустил свой тест и выдает ошибку, увиденную на прилагаемых изображениях. Я также скопировал/наклеил мой простой тестовый скрипт и сообщения журнала ошибок, которые были результатом запуска моего теста «komootTest».java.lang.NullPointerException при запуске теста на Android в IntelliJ (OSX)
Я смущен насчет ошибки, которую бросают. По строке 44 я создаю экземпляр переменной, которая является элементом в komoot (кнопка входа) с правильным идентификатором. Зачем в этом случае было бы выбросить нулевое исключение? Я могу предоставить более подробную информацию по мере необходимости, спасибо!
Вот код для моего тестового 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
Вместо изображения, вы должны поместить код на вопрос –
Я изменил его так, чтобы код находится в вопросе –
Уверены ли вы, что все ваши библиотеки/драйверы установлены правильно? –