I am trying to write a python code to verify for the presence of .mp3
and corresponding .json
file in the dropbox.
dropboxmp3txt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View/android.widget.TextView[contains(@index, "1")]')
print dropboxmp3txt.text
This gives me the output :
abc2016-05-05, 10.38.26.mp3
Which is perfectly fine!!!
I need the similar xpath to find the .json
text. The one which is below the .mp3
, in the figure.
I tried doing :
dropboxmp3txt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[0]/android.widget.TextView[contains(@index, "1")]')
print dropboxmp3txt.text
dropboxjsontxt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[1]/android.widget.TextView[contains(@index, "1")]')
print dropboxjsontxt.text
But, that gave me an error :
Traceback (most recent call last):
File "dropboxshare.py", line 136, in test_1_view_checkbox
dropboxtxt = self.driver.find_element_by_xpath('//android.widget.ListView/android.view.View[0]/android.widget.TextView[contains(@index, "1")]')
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 258, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
There is no ID specified for the 2 texts.. Only thing that is unique in both is the extension (.mp3 and .json)..
How can I retrieve these 2 texts ??
The textsabc2016-05-5,10.38.26.mp3
andabc2016-05-5,10.38.26.json
I can't enter directly..
like:xpath("//android.widget.ListView/android.view.View/android.widget.TextView[@index='1' and @text='abc2016-05-05, 10.38.26.mp3' ]")
xpath("//android.widget.ListView/android.view.View/android.widget.TextView[@index='1' and @text='abc2016-05-05, 10.38.26.json' ]")
Because, some other .mp3
and .json
might come during the next run and occupy those place..
It changes during runtime.. I need to know what text is present in that location first.
How can I retrieve it..
ANY IDEA ???