Hi, I’m trying to setup appium for cross platform testing. I have problem with setup. My code runs perfectly without annotations, but if I’m trying to use annotations I’m getting strange error messages and couldn’t figure out where the problem is. I wrote example script. Maybe someone can help me to understand how to do it properly.
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import org.junit.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.appium.java_client.pagefactory.*;
import org.openqa.selenium.support.PageFactory;
public class TestAnottationApp {
AppiumDriver driver;
@Before
public void setup() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("deviceName", "iPhone X");
capabilities.setCapability("platformVersion", "11.2");
capabilities.setCapability("bundleID", "com.test.app");
capabilities.setCapability("app", "/Users/Build/Products/Debug-iphonesimulator/test.app");
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
AppiumFieldDecorator decorator = new AppiumFieldDecorator(this.driver, 200, TimeUnit.SECONDS);
PageFactory.initElements(decorator, this);
}
@After
public void teardown(){
driver.quit();
}
@iOSFindBy(id = "bar_menu")
@AndroidFindBy(id = "com.test:id/menu")
public MobileElement burgerButton;
@Test
public void selectMenu() {
//driver.findElementByAccessibilityId("bar_menu").click(); //working code without annotation
burgerButton.click(); //this code does't work
}
}