selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters

I am able to launch application. i.e splacescreen
when loginActivity apperas it have two pop for assing permission . i am able to perfoem click using python script . but when plan loginscreen appear it gives me this error
image
button = driver.find_elements_by_class_name(“android.widget.Button”)

Can you paste your Python test script here?

from appium import webdriver
import time
import os

PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(file), p))
desired_caps = {}
desired_caps[‘platformName’] = ‘Android’
#desired_caps[‘appiumVersion’] = ‘1.4.16.1’
#desired_caps[‘platformVersion’] = ‘4.2’
desired_caps[‘deviceName’] = ‘520377bf4269b355’
desired_caps[‘noReset’] = True
#desired_caps[‘app’] = PATH(‘xxx.apk’);
desired_caps[‘appPackage’] = ‘com.xxx’
desired_caps[‘appActivity’] = ‘com.xxx.setup.SplashScreen’
driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub’, desired_caps)

Test Actions here…

driver.implicitly_wait(15)

button = driver.find_elements_by_class_name(“android.widget.Button”)
button[1].click();

button1 = driver.find_elements_by_class_name(“android.widget.Button”)
button1[1].click();

time.sleep(30)

button2=driver.find_elements_by_class_name(“android.widget.TextView”)
print button2

driver.quit()

button2 print [ ] null array

Assuming you are trying to click on the ‘Login’ button, can you try this?

button2 = driver.find_element_by_xpath('//android.widget.Button[@text = "LOGIN"]')
print button2

If you want to click on the Login button:

button2 = driver.find_element_by_xpath('//android.widget.Button[@text = "LOGIN"]')
button2.click()

appium terminal shows
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: [“xpath”,"//andr
oid.widget.Button[@text = “LOGIN”]",“ff49d83b-635f-4073-8731-3717fca178d1”]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class
name, accessibility id, -android uiautomator
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class
name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 15000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:
“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.Button[@text =
“LOGIN”]",“context”:"",“multiple”:false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:
“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widg
et.Button[@text = “LOGIN”]",“context”:"",“multiple”:false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘//android.widget.But
ton[@text = “LOGIN”]’ using ‘XPATH’ with the contextId: ‘’ multiple: false

its not going ahead

************when loginActivity launch appium shows

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Cle
aring Accessibility cache and retrying.
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘android.widget.Butto
n’ using ‘CLASS_NAME’ with the contextId: ‘’ multiple: true
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLASS=andro
id.widget.Button]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelect
or[CLASS=android.widget.Button]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSe
lector[CLASS=android.widget.Button, INSTANCE=0]

can you click on the ‘Login’ button in your uiautomator tool and share a screenshot.

hi
i am able to run after change android device having M version.
previos version was N

now i am able to sendkey to username and password . but keyboard hide login button .
not able to click on login.
====Please Help======

driver.find_element_by_id(“com.***:id/editTextUsername”).clear()
driver.find_element_by_id(“com***:id/editTextUsername”).send_keys(‘harsha’)
driver.find_element_by_id(“com.***:id/editTextPwd”).clear()
driver.find_element_by_id(“com.***:id/editTextPwd”).send_keys(‘[email protected]’)
driver.hide_keyboard()

driver.find_element_by_id(“com.***:id/activity_login”).click()

oh that’s great. For click login button does appium says element not found?

no.
there is no error.
But why it is not working on andorid N?
i have latest appium version

add this to your desired capabilities

automationName: 'uiautomator2'

Thanks . working on both devices.
desired_caps[‘automationName’] = ‘uiautomator2’
install uiatomator2 and set JAVA_HOME

I am not able to access webview element using uiautomator2.
i have added webview in android screen
it is possible in default uiatomator
Please help

@Venkatesh_Akula

Hey, tried several ways to find my element, error still shows up.

  1. From the below list , tried all locator strategy, but no help.

#elu = driver.find_element_by_xpath("//*[contains(@text, ‘Baddebt Collection’)]")
#elu.click()

elv = driver.find_element_by_xpath(’//android.widget.TextView[@text= “Baddebt Collection”]’)
elv.click()

#elk = driver.find_element_by_name(“Baddebt Collection”)
#elk.click()

#el78 = driver.find_element_by_id(“com.ambs.mobile:id/txtValue_Spinner”)
#el78.click()

#elb = driver.find_element_by_xpath("//*[@name=‘Baddebt Collection’]")
#elb.click()

The clickable flag shows ‘False’ in the inspector. Can you check with your developers to see if they can set it to True and retry?