question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch to webview, the pagesource obtained is still a native element

See original GitHub issue

hello, After clicking the element with flutter, switch to the webview page, you can switch normally, but the H5 element cannot be obtained, and the printed pagesource is also a native element。 My environment is Android 10, python, the following is the source code and the printed log: `class FlutterTest(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps[‘platformName’] = ‘Android’ desired_caps[‘platformVersion’] = ‘10’ desired_caps[‘deviceName’] = ‘CLB0218904005263’ desired_caps[‘appPackage’] = ‘com.tencent.docs’ desired_caps[‘automationName’] = ‘Flutter’ desired_caps[‘appActivity’] = ‘com.tencent.docs.DocsFlutterActivity’ desired_caps[‘noReset’] = “True” desired_caps[‘recreateChromeDriverSessions’] = True desired_caps[‘chromeOptions’] = {‘w3c’: False} # desired_caps[‘enableWebviewDetailsCollection’] = True desired_caps[‘chromedriverExecutableDir’] = r’C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\79.0’

    self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    self.finder = FlutterFinder()

def test_flutter(self):
    time.sleep(6)
    finder = self.finder.by_text("test111")
    text_ele = FlutterElement(self.driver, finder)
    text_ele.click()
    self.driver.switch_to.context('NATIVE_APP')
    time.sleep(15)
    print(self.driver.contexts)
    contexts = self.driver.contexts
    self.driver.switch_to.context('WEBVIEW_com.tencent.docs')
    print(self.driver.context)
    print(self.driver.page_source)
    time.sleep(5)

    windows = self.driver.window_handles
    for window in windows:
        time.sleep(5)
        self.driver.switch_to.window(window)
        if self.driver.title == 'test111':
            break
    print(self.driver.title)
    time.sleep(5)
    print(self.driver.page_source)
    more = self.driver.find_element_by_class_name('mobile-component-star-v2  ')
    more.click()
    time.sleep(30)

def tearDown(self):
    # self.driver.quit()
    pass`

log: image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
teeenchocommented, May 4, 2021

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android webview contains empty html source, can't ... - GitHub
Still i am not able to see any element after login page. checked with pagesource. It shows empty body, but the chrome inspect...
Read more >
Elements in webview are not found in webview context (ios)
I've got a webview in this hierarchy: ... When I look for the elements while still in the native context, they are all...
Read more >
Appium:Android WebView Chrome Tab Elements Not ...
On switching to WEBVIEW_chrome , I'm getting more than 1 window handles. I iterate through each one of them to find my element....
Read more >
Switch to Webview - Google Groups
When you get the source of the app, do you see a webview element? ... Below is the page source I got, it...
Read more >
How To Get Page Source In Selenium Using Python?
The easiest way to describe an HTML web element would be, “any HTML tag that constitutes the HTML page source code is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found