I have single framework to work on both iOS and android devices .According to my input, it’s opening simulator or emulator and installing the app. But when it try to interact with Web element , it says null pointer exception.
If i use “By” it’s working fine but i can’t use “By” locator as element locator for ios and android is different. Can somebody facing this issue? I’m thinking it may be related to lib incompatibility ,not sure? I tried different InitElement everything is showing null pointer exception in web element.
Elements:
@iOSXCUITFindBy(xpath = “//XCUIElementTypeImage[@name=‘account-tab’]”)
@AndroidFindBy(xpath = “//android.widget.TextView[@text=‘Account’]”)
public static WebElement ACCOUNT_TAB;
Methods:
public class TabMethods extends UIInteractionSteps {
Logger logger = LoggerFactory.getLogger(TabMethods.class);
public boolean isAccountTabDisplayed() {
return $(TabElements.ACCOUNT_TAB).isDisplayed();
}
@Step("Click on account tab")
public void clickOnAccountTab() {
$(TabElements.ACCOUNT_TAB).click();
}
}
My driver Initialisation class:
public AppiumPageObject(AppiumDriver driver) {
this.driver = driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
Build gradle:
dependencies {
implementation ‘io.cucumber:cucumber-java:7.8.1’
implementation ‘io.cucumber:cucumber-core:7.8.1’
implementation ‘net.serenity-bdd:serenity-stats:3.6.9’
implementation ‘net.serenity-bdd:serenity-single-page-report:3.6.9’
implementation ‘net.serenity-bdd:serenity-core:3.6.12’
implementation 'cglib:cglib:3.3.0'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'org.seleniumhq.selenium:selenium-api:3.9.1'
implementation 'io.appium:java-client:8.3.0'
implementation 'org.seleniumhq.selenium:selenium-java:4.7.0'
implementation 'org.seleniumhq.selenium:selenium-remote-driver:4.7.0'
implementation 'org.seleniumhq.selenium:selenium-support:4.7.0'
implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.7.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.4'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.4'
implementation 'com.opencsv:opencsv:5.1'
implementation 'cglib:cglib:3.3.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.3'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.12.3'
implementation 'org.slf4j:slf4j-log4j12:2.0.5'
implementation 'org.junit.jupiter:junit-jupiter:5.8.1'
compileOnly 'org.projectlombok:lombok:1.18.24'
implementation 'com.googlecode.lambdaj:lambdaj:2.3.3'
testImplementation 'net.serenity-bdd:serenity-junit:3.6.9'
testImplementation 'net.serenity-bdd:serenity-cucumber:3.6.9'
testImplementation 'net.serenity-bdd:serenity-screenplay:2.4.34'
testImplementation 'net.serenity-bdd:serenity-screenplay-webdriver:2.4.34'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'com.saucelabs:saucerest:1.2.0'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
}
SW details:
Appium v2.0.0-beta.55
npm 8.11.0
node v16.15.1
java.version: ‘11.0.18’
Other version details in gradle
Error:
[Appium] Welcome to Appium v2.0.0-beta.55
[Appium] Non-default server args:
[Appium] { address: ‘127.0.0.1’, port: 20383, sessionOverride: true }
[Appium] Attempting to load driver xcuitest…
[debug] [Appium] Requiring driver at /Users/390099/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver uiautomator2…
[debug] [Appium] Requiring driver at /Users/390099/node_modules/appium-uiautomator2-driver
[Appium] Attempting to load driver chromium…
[Appium] Could not load driver ‘chromium’, so it will not be available. Error in loading the driver was: Could not find a driver installed at /Users/390099/node_modules/appium-chromium-driver
[debug] [Appium] ReferenceError: Could not find a driver installed at /Users/390099/node_modules/appium-chromium-driver
[debug] [Appium] at DriverConfig.require (/opt/homebrew/lib/node_modules/appium/lib/extension/extension-config.js:539:13)
[debug] [Appium] at /opt/homebrew/lib/node_modules/appium/lib/extension/index.js:83:46
[debug] [Appium] at Array.map ()
[debug] [Appium] at getActiveDrivers (/opt/homebrew/lib/node_modules/appium/lib/extension/index.js:80:10)
[debug] [Appium] at main (/opt/homebrew/lib/node_modules/appium/lib/main.js:303:41)
[Appium] Appium REST http interface listener started on 127.0.0.1:20383
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘XCUITest’)
[Appium] - [email protected] (automationName ‘UiAutomator2’)
[Appium] - [email protected] (automationName ‘Chromium’)
[Appium] No plugins have been installed. Use the “appium plugin” command to install the one(s) you want to use.
[HTTP] --> GET /status
[HTTP] {}
[debug] [[email protected]] Calling AppiumDriver.getStatus() with args: []
[debug] [[email protected]] Responding to client with driver.getStatus() result: {“build”:{“version”:“2.0.0-beta.55”}}
[HTTP] <-- GET /status 200 2 ms - 47
[HTTP]
2023-03-07 10:15:05 INFO AppiumServerController:53 - Appium server started successfully
2023-03-07 10:15:05 INFO SerenityReporter:196 - Running feature from file:///Users/390099/Documents/mob-qa-twlapp-automation/src/test/resources/features/Account/AccountSignIn.feature
2023-03-07 10:15:05 INFO :100 -
_______. _______ .______ _______ .__ __. __ .___________.____ ____ / || ____|| _ \ | ____|| \ | | | | | |\ \ / /
| (----
| |__ | |_) | | |__ | \| | | |
—| |----\ \/ / \ \ | __| | / | __| | .
| | | | | _ /
.----) | | |___ | |\ ----.| |____ | |\ | | | | | | |
|/ ||| | `.||______||| __| || || |_|News and tutorials at http://www.serenity-bdd.info
Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/
Join the Serenity Community on Gitter: https://gitter.im/serenity-bdd/serenity-core
Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport2023-03-07 10:15:05 INFO :121 - Test Suite Started: SignIn red App From Account page
2023-03-07 10:15:05 INFO SerenityReporter:196 - Running feature from file:///Users/390099/Documents/mob-qa-twlapp-automation/src/test/resources/features/Account/AccountSignIn.feature
2023-03-07 10:15:05 INFO :121 - Test Suite Started: SignIn red App From Account page@AccountLogin @Smoke
Scenario: SIG-001- Valid customer login to the red app from Account page # src/test/resources/features/Account/AccountSignIn.feature:8
2023-03-07 10:15:05 INFO SerenityReporter:196 - Running feature from file:///Users/390099/Documents/mob-qa-app-automation/src/test/resources/features/Account/AccountSignIn.feature
2023-03-07 10:15:06 INFO :141 -
|_ | | | / | | | / | | | /\ | _ \ | | | | | \
| | | | _ \ | | _ \ | | / _ \ | / | | | | | |) |
|| || |/ || |/ || // _\ ||\ || |___| |___/SIG-001- Valid customer login to the red app from Account page(signin–app-from-account-page;sig-001–valid-customer-login-to-the-app-from-account-page)
2023-03-07 10:15:06 INFO DataHelper:37 - Environment is :
UAT App is launched successfully
Given The customer launch app # com.app.stepDefinitions.Cucumber.CommonStepsDef.theCustomerLaunchApp()
And customer clicks on “Account” tab # com…app.stepDefinitions.Cucumber.TabStepsDef.customerClicksOnTab(java.lang.String)
> java.lang.NullPointerException
at net.serenitybdd.core.pages.WebElementFacadeImpl.isDisplayed(WebElementFacadeImpl.java:1321)
at com.app.pages.Tab.TabMethods.isAccountTabDisplayed(TabMethods.java:17)