0

variable expansion is not happening inside multiple quotes. Here is the code

products = ['One','Two','Three'] 
for i in range(0,len(products)):
     el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("{}")').format(products[i])
                print (el)

expected result should be:

el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("One")')

Error Message:

File "temp_test.py", line 84, in test_product
    el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("{}")').format(products[i])
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

Please help me to resolve this issue!!!

code_seeker
  • 112
  • 2
  • 12

1 Answers1

0

Finally, got the answer with multiple tries(almost half a day). Its simple, the .format(products[i]) should specified inside the brackets() and end of the quotes.

products = ['One','Two','Three'] 
for i in range(0,len(products)):
     el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("{}")'.format(products[i]))
                print (el)
code_seeker
  • 112
  • 2
  • 12