Can't Find Element In webview

i used find_element_by_name() then click() twice , the first one found the element and after the click() it opened another url as expected , and the pages is fully loaded . then comes to the second find_element_by_name , but it it failed to find the element , which is apparently on the page . here what i did :

  1. i print out the contexts , which i shows i still in the same webView as the last click()
  2. i printed out page_source info twice , the first print out the whole page info , but the second one print out nothing , and the process stoped there .

here’s my python codes:

from appium import webdriver
from time import sleep

desired_caps = {
'platformName': 'Android',
'platformVersion': '4.4.2',
'deviceName': 'T8D3C615717324220',
'app': '',
'appPackage': 'com.tencent.mm',
'appActivity':'.ui.LauncherUI',
'unicodeKeyboard': True,
'resetKeyboard': True,
'resetKeyboard': True,
'chromeOptions': {'androidProcess': 'com.tencent.mm:tools'}
}


driver = webdriver.Remote('http://localhost:4735/wd/hub', desired_caps)
driver.implicitly_wait(5)
driver.find_element_by_android_uiautomator("new UiSelector().text(\"contacts\")").click()
driver.find_element_by_id("com.tencent.mm:id/qa").click()
driver.find_element_by_id("com.tencent.mm:id/s4").click()
driver.find_element_by_name("myapp").click()
print(driver.contexts)
driver.find_element_by_name("myappMenu").click()
sleep(10)
print(driver.contexts)
driver._switch_to.context('WEBVIEW_com.tencent.mm:tools')
print(driver.page_source)
driver.find_element_by_xpath("/html/body/div[4]").click()
print("---------")
sleep(5)
print(driver.contexts)
print(driver.page_source)
driver.find_element_by_name("secondBuy").click()
driver.find_element_by_xpath("/html/body/div[4]").click()
sleep(5)
driver.quit()

any tips or help to solve this problem ? tks advance … :slight_smile:

is anyone can help us, from my side i get the same error as well. :pray: