Good day, I tried also the code you have provided from the previous comment and wondering how I can select/click the element not visible on the panel of my mobile android device. Provided below are my code and new UiSelector is scrolling and working on some app but for no apparent reason it does not works on the app our dev is currently creating. Details are given below.
Kindly help as I am still trying to learn Appium. Thank you and good day.
appium --1.16.0
java version “1.8.0_231”
code:
public static void openKYC() throws Exception {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "CAM-L21");
cap.setCapability("udid", "LHTDU17601000834");
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "6.0");
cap.setCapability("automationName", "UiAutomator1");
cap.setCapability("appPackage", "com.cimb.ekyc");
cap.setCapability("appActivity", "com.cimb.ekyc.MainActivity");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver<MobileElement>(url, cap);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
System.out.println("KYC Application Test Started...");
driver.findElement(By.className("android.widget.Button")).click();
driver.findElementByXPath("//android.view.View[@text='E-i navigation icon EcoSave Savings Account-i Online, paperless, and environmentally friendly']").click();
((FindsByAndroidUIAutomator<MobileElement>) driver).findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"Green Environmental Activities\").instance(0))");
}
}
On Appium server: there is an error (UiObjectNotFoundException) as per screenshot below:
wow. this is web view! which may work tricky. better switch context to web and use “click()” on element as with usual web. do not use uiSelector. imagine you are automating web.
After you switch to webView you will see ALL screen elements even outside visible area.
Previously, I was automating on our angular web using a Protractor but our team creates another app using PWA for a mobile wherein the customer can select accessing thru web (automation completes) and thru an app (PWA, ongoing automation) in mobile but experiencing problem scrolling down to certain elements.
Can you help elaborate further as I am not getting you. You mean I go use Protractor again? or should I use Aappium for the mobile app testing…Kindly help. thank you, Aleksei.
I tried putting the code as shown below, I paste the code you have provided below after I click the open account and loads to a web view as shown below…Do I need to change something here on the given code? Thanks
I did my code and I synched my chrome driver but received error 404 as shown below, how to click on the text ? Am I using the right selector for selenium/appium webview -> By.linkText . Thanks Aleksei
Thread.sleep(5000);
**Set<String> contexts = driver.getContextHandles();**
for(String contextName: contexts)
{
System.out.println(contextName);
}
driver.context("WEBVIEW_com.cimb.ekyc");
driver.executeScript("window.scrollTo(0,900);");
driver.findElement(By.linkText("R navigation icon Regular Savings Account Unlock higher interest rates as you save more")).click();
Thread.sleep(5000);
driver.quit();
Error in Appium:
Got an unexpected response with status 404: {“value”:{“error”:“no such element”,“message”:"no such element: Unable to locate element: {“method”:“link text”,“selector”:“R navigation icon Regular Savings Account Unlock higher interest rates as you save more”}\n (Session info:
I got the output in XML and it is raw format. I paste in my Notepad++, which value you want me to search in here?.
Here is the value I am looking for → <android.view.View index=“11” text=“R navigation icon Regular Current Account Your payment and trading activities are made easy” class=“android.view.View” package=“com.cimb.ekyc” content-desc=“” checkable=“false” checked=“false” clickable=“true” enabled=“true” focusable=“true” focused=“false” scrollable=“false” long-clickable=“false” password=“false” selected=“false” bounds=“[70,2958][322,1208]” resource-id=“” instance=“18”/>
How to click or select this element? I was able to scroll and see this value in my mobile panel device but unable to click on it, clicking it will result to 404
Good morning, I have now the formatted XML, how to select this and what selector to use to select the value that I want if the content-desc and resource-id are all empty? Thank you.
I coded like this: --is this syntax possible on webview?
driver.findElement(By.xpath("//android.view.View[@text=‘R navigation icon Regular Current Account Your payment and trading activities are made easy’ and @index=‘11’]")).click();
Error:
ProxyRequestError: Could not proxy command to remote server. Original error: 404 - {“value”:{“error”:“no such element”,“message”:"no such element: Unable to locate element
Ok, the routine you have shared me on the earlier comment. switching to web view.
But when I paste it and tried using it, having error on the line of code below
“Jsoup cannot be resolved” – is there any import code for this?
I have the pagesource, using the driver.getPageSource() and got the value as
<android.view.View index=“11” text=“R navigation icon Regular Current Account Your payment and trading activities are made easy” class=“android.view.View” package=“com.cimb.ekyc” content-desc="" checkable=“false” checked=“false” clickable=“true” enabled=“true” focusable=“true” focused=“false” scrollable=“false” long-clickable=“false” password=“false” selected=“false” bounds="[70,2958][322,1208]" resource-id="" instance=“18”/>