0

I am trying to automate a scenario in an android application using appium, java. I need to scroll down to an element on the screen to enter a text value. I'm initializing the elements using page factory as shown below.

@AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"com.call4site.handymanservices:id/email\"))")
private WebElement txt_email;

I'm getting a strange error in console as below.

org.openqa.selenium.InvalidSelectorException:
Unsupported CSS selector '*[name='txt_email']'. Reason: 'Error: 'name' is not a valid attribute. Supported attributes are 'checkable, checked, clickable, enabled, focusable, focused, long-clickable, scrollable, selected, index, instance, description, resource-id, text, class-name, package-name''
For documentation on this error, please visit: https://selenium.dev/exceptions/#invalid_selector_exception
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [da3c259c-cf9d-4457-967a-060eadf5f643, findElement {using=css selector, value=*[name='txt_email']}]
Capabilities {appium:app: C:\Users\laksh\Downloads\ha..., appium:appPackage: com.call4site.handymanservices, appium:automationName: uiautomator2, appium:databaseEnabled: false, appium:
desired: {app: C:\Users\laksh\Downloads\ha..., automationName: uiautomator2, deviceName: Android Emulator, platformName: android, platformVersion: 11.0, udid: emulator-5554}, appium:de
viceApiLevel: 30, appium:deviceManufacturer: unknown, appium:deviceModel: Android SDK built for x86, appium:deviceName: emulator-5554, appium:deviceScreenDensity: 560, appium:deviceScr
eenSize: 1440x2560, appium:deviceUDID: emulator-5554, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:pixelRatio: 3.
5, appium:platformVersion: 11, appium:statBarHeight: 84, appium:takesScreenshot: true, appium:udid: emulator-5554, appium:viewportRect: {height: 2308, left: 0, top: 84, width: 1440}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: ANDROID}
Session ID: da3c259c-cf9d-4457-967a-060eadf5f643
        at tests.signUpTests.signUpAsNewUser(signUpTests.java:32)

But if I use the following code to initialize the element, then I'm able to scroll down and enter text to it. Has anyone faced this issue?

WebElement txt_email = driver.findElement(AppiumBy.androidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"com.call4site.handymanservices:id/email\"))"));
u_u-de
  • 103
  • 9
  • Are you sure the error is logged on that specific line of code? It seems weird that the error mentions "*[name='txt_email']" while the code you're showing does not refer to this at all. – valies Nov 10 '22 at 09:39

0 Answers0