I have this screen in an android application.
I'm trying to run a method in order to check the number displayed in the car's image and find the first one different from zero then click on the picture that contain this number .
I tried this code:
public void test5_MAP_Assets_Position(String XX) {
try {
Assert.assertTrue( Integer.parseInt(XX)>Integer.parseInt("0"));
driver.findElement(By.xpath("//*[@text='"+XX+"']")) ;
driver.findElement(By.xpath("//*[@id='view_asset_item_image_view' and (./preceding-sibling::* | ./following-sibling::*) ] and //*[@text>='"+XX+"']")).click();
}
catch (AssertionError e) {
}
}
}
I got this error :
[RemoteTestNG] detected TestNG version 6.14.2
Jan 30, 2019 9:52:27 AM io.appium.java_client.remote.AppiumCommandExecutor$1
lambda$0
INFO: Detected dialect: OSS
[Utils] [ERROR] [Error] org.testng.TestNGException:
Cannot inject @Test annotated Method [test5_MAP_Assets_Position] with
[class java.lang.String].
For more information on native dependency injection please refer to
http://testng.org/doc/documentation-main.html#native-dependency-injection
at org.testng.internal.Parameters.checkParameterTypes(Parameters.java:407)
FAILED: test5_MAP_Assets_Position org.testng.TestNGException:
Cannot inject @Test annotated Method [test5_MAP_Assets_Position] with [class java.lang.String].
For more information on native dependency injection please refer to
http://testng.org/doc/documentation-main.html#native-dependency-injection
Please help me to fix this problem.
XX
should be a local variable and not method parameter:
public void test5_MAP_Assets_Position() {
String XX = "1234";
try {
Assert.assertTrue( Integer.parseInt(XX)>Integer.parseInt("0"));
driver.findElement(By.xpath("//*[@text='"+XX+"']")) ;
driver.findElement(By.xpath("//*[@id='view_asset_item_image_view' and (./preceding-sibling::* | ./following-sibling::*) ] and //*[@text>='"+XX+"']")).click();
Or use Parameters with DataProviders
you can use a Data Provider to supply the values you need to test. A Data Provider is a method on your class that returns an array of array of objects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.