Here:
- POM: (Although recently I removed that exlcusion from java client)
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.3.0</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.5.3</version>
</dependency>
</dependencies>
- Page with locators: (this allow is like "Accessibility, so this might be wrong, but I tried a bunch of them)
public class loginPage {
public static void initializePageObjects(AppiumDriver driver) {
PageFactory.initElements(new AppiumFieldDecorator(driver), loginPage.class);
}
@iOSXCUITFindBy(id = "Allow")
public static WebElement allowButton;
@iOSXCUITFindBy (iOSClassChain = "**/XCUIElementTypeOther[`label == The App"`]/XCUIElementTypeOther/XCUIElementTypeImage")
public static WebElement logo;
}
- Main method: (sam with driver, now is IOS driver, i tried with Appium or Remote as well
MutableCapabilities caps = new MutableCapabilities();
caps.setCapability("platformName", "iOS");
caps.setCapability("appium:deviceName", "iPhone 14 Simulator");
caps.setCapability("appium:deviceOrientation", "portrait");
caps.setCapability("appium:platformVersion", "16.4");
caps.setCapability("appium:automationName", "XCUITest");
caps.setCapability("appium:app","/Users/XXX/Documents/Apps/iOS/XXX.app");
caps.setCapability("appium:udid","509860CD-4C17-4C62-9523-715AE37C2603");
URL url = new URL("http://localhost:4723");
Appium driver = new IOSDriver(url, caps);
loginPage.initializePageObjects(driver);
Thread.sleep(5000);
allowButton.click();
Thread.sleep(2000);
System.out.println(logo.isDisplayed());
Errors:
With appium field decorator:
Exception in thread “main” java.lang.NullPointerException
at org.example.Main.main(Main.java:30)
Process finished with exit code 1
Without:
Exception in thread “main” org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Build info: version: ‘4.10.0’, revision: ‘c14d967899’
System info: os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘11.4’, java.version: ‘11.0.13’
Driver info: io.appium.java_client.ios.IOSDriver
Command: [fe0e3508-eec0-4511-9ad8-66bcb6f55603, findElement {using=css selector, value=*[name=‘allowButton’]}]
Capabilities {appium:app: /Users/XXX/Docume..., appium:automationName: XCUITest, appium:databaseEnabled: false, appium:deviceName: iPhone 14 Pro Simulator, appium:deviceOrientation: portrait, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: false, appium:platformVersion: 16.4, appium:takesScreenshot: true, appium:udid: 509860CD-4C17-4C62-9523-715..., appium:webStorageEnabled: false, platformName: IOS}
Session ID: fe0e3508-eec0-4511-9ad8-66bcb6f55603
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:199)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:132)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:51)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElement(ElementLocation.java:165)
at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:59)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:350)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at org.openqa.selenium.By$PreW3CLocator.findElement(By.java:427)
at org.openqa.selenium.By$ByName.findElement(By.java:236)
at org.openqa.selenium.support.ByIdOrName.findElement(ByIdOrName.java:49)
at org.openqa.selenium.remote.ElementLocation$ElementFinder$1.findElement(ElementLocation.java:139)
at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:81)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:350)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:68)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy8.click(Unknown Source)
at org.example.Main.main(Main.java:30)
Process finished with exit code 1
“Help me Obi Wan Kenobi, you are my only hope”