How to get page-source of an element in mobile native app by selenium script?
10,311
There is getPageSource() method:
driver.getPageSource();
Update
To get source code of specific element (including element's tag):
element.getAttribute('outerHTML')
Author by
pr4bh4sh
Updated on June 04, 2022Comments
-
pr4bh4sh about 2 years
I'm using Appium for automation of mobile application and I want is just the pagesource of an element of a native app. I have googled a lot and found that its possible for webpages but did not get any solution for mobile's native app. like below examples.
elem.getAttribute("innerHTML");
OR
WebElement element = driver.findElement(By.id("foo")); String contents = (String)((JavascriptExecutor)driver).executeScript("return arguments[0].innerHTML;", element);
-
pr4bh4sh about 9 yearsI don't want page source of entire page, I just want the page source of a specific element. Something like <h1 name="title">Title</h1>
-
Kirill about 9 years@pr4bh4sh,
element.getAttribute('innerHTML')
? -
Kirill about 9 yearsProbably you need this:
element.getAttribute('innerHTML')
-
kiedysktos about 8 yearsfor iOS it doesn't work. "UIAElements don't have the attribute 'outerHTML'" - that's what Appium says
-
Kirill about 8 years@kiedysktos, try to change context from native to web.
-
Tomáš Hübelbauer about 2 yearsFor CodeceptJS: await I.grabSource()