Unable to Perform Any Click Action With Page Object Model
See original GitHub issueThe problem
I am using all latest jar file Selenium 3.7.1 java-client 5.0.4 appium 1.7.1
Unable to perfrom any click action using Page Object Model
if i am using old jar files then everything is working fine.
Actual Problem :- I have created Page Object Model and i am trying to perform click or any function using POM . but application is crashing after sucessfully launch . If i am not using POM and assinging everying in same class file then automation script is working fine.
Details
If necessary, describe the problem you have been experiencing in more detail.
Link to Appium logs
The server is running
[ADB] Running ‘C:\Users\MY PC\AppData\Local\Android\Sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“75c26c4c”,“shell”,“am”,“start”,“-W”,“-n”,“com.appotek.patient/com.appotek.patient.SplashActivity”,“-S”] [Appium] New AndroidDriver session created successfully, session e882bb91-88c9-40eb-a416-22e06705677c added to master session list [BaseDriver] Event ‘newSessionStarted’ logged at 1511594896102 (12:58:16 GMT+0530 (India Standard Time)) [MJSONWP] Responding to client with driver.createSession() result: {“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“UDiD”:“75c26c4c”,“app”:“C:\Users\MY PC\eclipse-workspace\PatientAutomationScript\libs\patient_latest_build_23rdnov2017.apk”,“appActivity”:“com.appotek.patient.SplashActivity”,“appPackage”:“com.appotek.patient”,“appium-version”:“1.7.1”,“deviceName”:“75c26c4c”,“platformName”:“Android”,“platformVersion”:“6.0.1”},“UDiD”:“75c26c4c”,“app”:“C:\Users\MY PC\eclipse-workspace\PatientAutomationScript\libs\patient_latest_build_23rdnov2017.apk”,“appActivity”:“com.appotek.patient.SplashActivity”,“appPackage”:“com.appotek.patient”,“appium-version”:“1.7.1”,“deviceName”:“75c26c4c”,“platformName”:“Android”,“platformVersion”:“6.0.1”,“deviceUDID”:“75c26c4c”,“deviceScreenSize”:“1080x1920”,“deviceModel”:“CPH1613”,“deviceManufacturer”:“OPPO”} [HTTP] <-- POST /wd/hub/session 200 63228 ms - 1020 [HTTP] --> POST /wd/hub/session/e882bb91-88c9-40eb-a416-22e06705677c/timeouts {“type”:“implicit”,“ms”:60000} [MJSONWP] Calling AppiumDriver.timeouts() with args: [“implicit”,60000,“e882bb91-88c9-40eb-a416-22e06705677c”] [BaseDriver] Set implicit wait to 60000ms [MJSONWP] Responding to client with driver.timeouts() result: null [HTTP] <-- POST /wd/hub/session/e882bb91-88c9-40eb-a416-22e06705677c/timeouts 200 21 ms - 76 [HTTP] --> DELETE /wd/hub/session/e882bb91-88c9-40eb-a416-22e06705677c {} [MJSONWP] Calling AppiumDriver.deleteSession() with args: [“e882bb91-88c9-40eb-a416-22e06705677c”] [BaseDriver] Event ‘quitSessionRequested’ logged at 1511594908477 (12:58:28 GMT+0530 (India Standard Time)) [Appium] Removing session e882bb91-88c9-40eb-a416-22e06705677c from our master session list [AndroidDriver] Shutting down Android driver [ADB] Getting connected devices… [ADB] 1 device(s) connected [ADB] Running ‘C:\Users\MY PC\AppData\Local\Android\Sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“75c26c4c”,“shell”,“am”,“force-stop”,“com.appotek.patient”] [ADB] Pressing the HOME button [ADB] Getting connected devices… [ADB] 1 device(s) connected [ADB] Running ‘C:\Users\MY PC\AppData\Local\Android\Sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“75c26c4c”,“shell”,“input”,“keyevent”,3] [AndroidBootstrap] Sending command to android: {“cmd”:“shutdown”} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“shutdown”} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN [AndroidBootstrap] Received command result from bootstrap [UiAutomator] Shutting down UiAutomator [UiAutomator] Moving to state ‘stopping’ [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[AndroidBootstrap] [UIAUTO STDOUT] Time: 21.637
[AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state ‘stopped’
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\MY PC\AppData\Local\Android\Sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“75c26c4c”,“shell”,“ps”]
[ADB] No uiautomator process found to kill, continuing…
[UiAutomator] Moving to state ‘stopped’
[Logcat] Stopping logcat capture
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\MY PC\AppData\Local\Android\Sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“75c26c4c”,“shell”,“am”,“force-stop”,“io.appium.unlock”]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles
capability if wanted.
[BaseDriver] Event ‘quitSessionFinished’ logged at 1511594916196 (12:58:36 GMT+0530 (India Standard Time))
[MJSONWP] Received response: null
[MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/e882bb91-88c9-40eb-a416-22e06705677c 200 7729 ms - 76
Code To Reproduce Issue [ Good To Have ]
One Class File :
package com.patient.pages;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.pagefactory.FieldDecorator; import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator;
public class SelectionScreen {
public static final String packageName = "com.appotek.patient";
AndroidDriver<MobileElement> driver;
public SelectionScreen(WebDriver driver){
this.driver = (AndroidDriver<MobileElement>)driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
@AndroidFindBy(id=packageName+":id/text_country")
MobileElement btncountrycode;
public void clickOnCountryCode() throws InterruptedException
{
btncountrycode.click();
}
}
Second Class File Test Case:
package com.patient.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test;
import com.patient.pages.SelectionScreen; import com.patient.setup.AppLaunch;
public class SelectionScreenTestCases
{
WebDriver driver;
AppLaunch applaunch;
SelectionScreen SSScreen;
@BeforeMethod
public void startapplication() throws InterruptedException
{
applaunch= new AppLaunch(driver);
this.driver=applaunch.launchApplication();
Thread.sleep(10000);
}
@Test
public void verifyCountry() throws InterruptedException
{
Thread.sleep(2000);
SSScreen = new SelectionScreen(driver);
Thread.sleep(10000);
SSScreen.clickOnCountryCode();
Thread.sleep(10000);
}
@AfterMethod
public void closeApplication()
{
driver.quit();
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top GitHub Comments
@aniboski Thanks a lot, this fixed worked for me like a charm. People should know that if they are using POM model they should add the above mentioned .jars files for its smooth functioning.
@TarunDabas86 I fixed the issue by downloading cglib-3.2.6.jar (https://github.com/cglib/cglib/releases) and asm-6.0.jar (https://forge.ow2.org/project/showfiles.php?group_id=23&release_id=6029)