2

Appium Python iOS

el.text and get_attribute('label') etc. all seem to pulling accessibility information. Is there a way to pull the actual text that is displayed on screen using Appium? I need to be able to pull for a given element.

cjg123
  • 473
  • 7
  • 23

4 Answers4

2

It does not return visible text if you use .text

You need to ask the developer to add a new attribute in the iOS code with the actual mention of the original url text. Then you will be able to see the new attribute in the Appium element locator table. If this is not done there is no value in the appium element locator table to give you the visible text

  • 1
    Could you ellaborate your answer a bit more? What should the OP do and why .text does not work? – flen Jul 08 '18 at 21:14
  • You need to ask the developer to add a new attribute in the iOS code with the actual mention of the original url text. Then you will be able to see the new attribute in the Appium element locator table. If this is not done there is no value in the appium element locator table to give you the visible text. – Sumanth Vakacharla Jul 09 '18 at 23:02
-1

You can use .text

element = driver.find_element_by_class_name("class_name").text
print(element)

it will return you text and verify f you required.

Raman
  • 444
  • 6
  • 21
-1

Try this one it will help you

element = driver.find_element_by_class_name("class_name").get_attribute('text')
print(element)

or Second one - Give you exact text from android ui

element = driver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.EditText\")").get_attribute('text')
print(element)
Pheepster
  • 6,045
  • 6
  • 41
  • 75
-1

I am quite sure, that .text will give you the element's text when the element is visible. Beware, Appium does give you an empty string here, if it deems the element not visible (out of screen- bounds or hidden or behind another element). If you need to get the text of elements which are not visible, you may try this one driver.find_element_by_class_name("class_name").get_attribute('textContent')

Pepe
  • 24
  • 2