Hello all,
I’m new to appium and I’m evaluating it for use in automated testing of an iPad application. So far my research has indicated it is the best fitting solution for our current testing framework since it has native python 3.x support, doesn’t rely on a particular testing framework, and it has the ability to test both iOS and Android. That being said I’ve been monkeying around with it the last few days and have a question related to XPath.
The general layout here is that we already have an application developed for iPads running iOS 8.x, and it has been a pain in the past to get the developers to go back and add ID attributes to GUI elements. I have not worked with XPath before, but reading through the working draft on W3C it seems to be very powerful and may fit my needs. Anyway to the point: I have Appium 1.3.6 running on a Mac Book running OS X 10.10.1, connected to an iPad Mini Retina. I’ve had no problems getting the application deployed from the Appium server onto the iPad. I’ve also gotten the inspector running nicely which gave me some hints as to how to use XPath the get handles on some of the objects. I’ve gotten the latest git repository of the appium client for python loaded onto another Linux machine on the same local network.
I can successfully get a handle onto our UIATabBar object using XPath by referencing it from the document root, but things fall apart when I try to access any UIAButtons on the tab bar via the tab bar. Perhaps I’m using XPath incorrectly, but a simple example will suffice to demonstrate the problem:
howard@0x0badbeef:~/repos/personal/python/appium$ python3.4
Python 3.4.2 (default, Nov 7 2014, 13:43:47)
[GCC 4.7.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from appium import webdriver
>>> caps = {
... "platformName": "iOS",
... "platformVersion": "8.1",
... "deviceName": "iPad Retina (921221VB-E282-46C4-BCF7-AE44DA7026F1)",
... "automationName": "Appium",
... "newCommandTimeout": "999999",
... }
>>> driver = webdriver.Remote("http://192.168.1.25:4723/wd/hub", caps)
>>> tabBar = driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIATabBar[1]")
>>> btn1 = tabBar.find_element_by_xpath("child::UIAButton[1]")
Traceback (most recent call last):
...
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
>>> btn1 = tabBar.find_element_by_xpath("child::UIAButton[@name='Videos']")
Traceback (most recent call last):
...
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
>>> btn1 = tabBar.find_element_by_class_name("UIAButton")
>>> btn1
<appium.webdriver.webelement.WebElement object at 0x7f191ac1c5f8>
>>> btn1 = driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIATabBar[1]/UIAButton[@name='Videos']")
>>> btn1
<appium.webdriver.webelement.WebElement object at 0x7f191ac1c0f0>
I had assumed that by calling the “find_element_by_xpath()” function on the WebElement object, the given web element (tabBar) would have become the current node in the XPath search. Is that incorrect? How would I go about searching from the TabBar rather than searching the entire DOM for the given object?
Thanks for any help!