0
變量擴展不會在多個引號內發生。下面是代碼python變量擴展在多引號中使用appium查找元素
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)
預期的結果應該是:
el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("One")')
錯誤消息:
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.
請幫我解決這個問題!