我想使用 selenium webdriver点击图片中显示的元素(紫色圆圈,中间有 M 字母)。
元素位于导航栏上。我尝试使用 Appium Desktop 查找元素,但未成功。
我的代码执行一切,直到导航栏打开。
# Android environment
import unittest
from appium import webdriver
from selenium.common.exceptions import NoSuchElementException
from appium.webdriver.common.touch_action import TouchAction
from time import sleep
class TESTZERO(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.0'
desired_caps['deviceName'] = 'JUST5 Blaster'
desired_caps['appPackage'] = 'com.android.vending'
desired_caps['appActivity'] = 'com.google.android.finsky.activities.MainActivity'
self.driver = webdriver.Remote('http://localhost:5000/wd/hub', desired_caps)
def test_accept(self):
"Test Accept button"
self.driver.implicitly_wait(20)
element = self.driver.find_element_by_id('com.android.vending:id/positive_button')
element.click()
element = self.driver.find_element_by_id('com.android.vending:id/navigation_button')
element.click()
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TESTZERO)
unittest.TextTestRunner(verbosity=2).run(suite)
任何想法如何找到并单击或点击此元素?