【发布时间】:2021-11-11 20:09:27
【问题描述】:
我正在尝试运行我的 TestNG 测试并收到此错误:
Cannot inject @Test annotated Method [Test1] with [class io.appium.java_client.android.AndroidDriver].
不知道必须做什么。我正在使用 Appium whit TestNG。
@Listeners(ExtentITestListenerAdapter.class)
public class TestNG {
public AppiumDriver <AndroidElement>driver;
@Test
public void Test1(AndroidDriver driver) {
MobileElement el1 = (MobileElement) driver.findElementById("skip_button");
el1.click();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
TouchAction touchAction = new TouchAction(driver);
touchAction.tap(new PointOption().withCoordinates(725, 993)).perform();
touchAction.tap(new PointOption().withCoordinates(293, 1005)).perform();
touchAction.tap(new PointOption().withCoordinates(1175, 1531)).perform();
touchAction.tap(new PointOption().withCoordinates(1166, 2029)).perform();
touchAction.tap(new PointOption().withCoordinates(763, 2036)).perform();
MobileElement el2 = (MobileElement) driver.findElementById("continue_button");
el2.click();
}
@BeforeClass
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("deviceName", "Pixel_4_2");
desiredCapabilities.setCapability("automationName", "UiAutomator2");
desiredCapabilities.setCapability("udid", "emulator-5554");
desiredCapabilities.setCapability("app", "C:\\Users\\Diego\\Desktop\\flow-music-develop-dev-debug-v0.11.0-SNAPSHOT-209.apk");
desiredCapabilities.setCapability("ensureWebviewsHavePages", true);
URL remoteUrl = new URL("http://localhost:4723/wd/hub");
driver = new AndroidDriver(remoteUrl, desiredCapabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@After
public void tearDown() {
driver.quit();
}
}
【问题讨论】:
-
方法
[coordsWizardFuncionando2]在哪里?你确定你提供了这个产生错误的类吗? -
是的,这是方法,我忘记在这里改名字了,但这是方法