qmetry / qaf

Quality Automation Framework for web, mobileweb, mobile native and rest web-service using Selenium, webdrier, TestNG and Java Jersey
https://qmetry.github.io/qaf
MIT License
254 stars 138 forks source link

QAFExtendendWebDriver is throwing error when using the AndridUIAutomator to scroll the page till end #417

Closed govindd06 closed 2 years ago

govindd06 commented 2 years ago

QAF Version

Note: only the latest version is supported

Steps To Reproduce

1. When I'm trying to scroll the page to find the mobile element (the elements are dynamic each time the xpath will get change)
2.
3.

Expected behavior

Using AndroidUIAutomator, it has to scroll/ swipe the till the end of the page

Actual behavior

It is not scrolling till the end of the page instead It is throwing error "The class com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver of the given context doesn't implement io.appium.java_client.FindsByAndroidUIAutomator nor io.appium.java_client.FindsByFluentSelector"

Is the issue reproducible on runner?

Test case sample

Please, share the test case (as small as possible) which shows the issue Using the below code snippet it has to scroll till end of the page driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true)).scrollToEnd(10)"));

But it is throwing error "The class com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver of the given context doesn't implement io.appium.java_client.FindsByAndroidUIAutomator nor io.appium.java_client.FindsByFluentSelector"

Ref: http://appium.io/docs/en/writing-running-appium/tutorial/swipe/android-tricks/

cjayswal commented 2 years ago

For your case, you can use native locator strategy directly without any code. Refer documentation for locating element. For example:

my.ele.loc = -android uiautomator=new UiScrollable(new UiSelector().scrollable(true)).scrollToEnd(10)
care.book.appointment.btn=-android uiautomator=new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("Book an appointment").instance(0))

you can use this locator as usual. For example:

driver.findElement("my.ele.loc")
//or
$("my.ele.loc").isPresent();

For other cases, If you are not using remote driver and you want to use under laying driver object you can use getUnderLayingDriver() method. For example, when you are using driver.name=appiumDriver and providing driver class in capability like example here, you can access AppiumDriver as below

AppiumDriver<WebElement> driver = (AppiumDriver<WebElement>)getDriver().getUnderLayingDriver();
govindd06 commented 2 years ago

Hi cjayswal,

Thanks a lot for your quick support. It is working for me. I have done the following changes.

MobileElement element = (MobileElement) getAppiumDriver().findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().scrollable(true))" + ".scrollIntoView(new UiSelector().text(\"Your_Text_to_Search\"))")); element.click();

Thanks 👍