question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Perform Any Click Action With Page Object Model

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Jeeveshkcommented, May 30, 2018

@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.

1reaction
aniboskicommented, Feb 11, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Action class is not working in Page Object Model
Action class is not working in POM. I have a method in Page where i am trying to move to an element and...
Read more >
Automation in Selenium: Page Object Model and Page Factory
We will take a look at automated tests in Selenium, and how we can employ Page Object model best practices to write maintainable...
Read more >
Page Object Model in Selenium Without Using Page Factory
Steps To Create A POM Without Page Factory Model · Open the URL of an application. · Type the Email Address and password...
Read more >
Page Object Model (POM) In Selenium With Examples || Toolsqa
How to use page object model in Selenium Webdriver. ... All you need to do is find the elements and perform actions on...
Read more >
Stop using Page Objects and Start using App Actions - Cypress
Page objects 1, 2 are intended to make end-to-end tests readable and ... The user can click on an element in our application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found