以前执行的时候都是很快的,查找元素很快,执行click或者send_key都很快,快到有时候还得加time.sleep。现在还是在原来的手机上运行脚本,但是速度变的像乌龟一样,几十秒执行一个点击事件,但是在模拟器上运行脚本的速度就跟原来的一样快,为什么现在真机就变慢了呢?很纳闷啊
class TestVivoAdd():
@classmethod
def setup_class(cls):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.1'
desired_caps['deviceName'] = '192.168.3.2:5555'
desired_caps['appPackage'] = 'com.apk'
desired_caps['appActivity'] = 'com.Activity'
desired_caps["ensureWebviewsHavePages"] = True
# 防止每次打开应用都会初始化
desired_caps['noReset'] = 'True'
cls.driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
# cls.driver.implicitly_wait(5)
@pytest.mark.run(order=1)
def test_qunzu_01(self):
driver = self.driver
driver.find_element_by_id("com.xinhooa.flygram.xy:id/iv_contact_nor").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/group_chat_tv").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/iv_back").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/iv_title_add").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/tv_group_chat").click()
driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout[2]/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.LinearLayout").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/tv_title_right").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/et_group_name").send_keys("test")
driver.find_element_by_id("com.xinhooa.flygram.xy:id/no_join_switch").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/tv_title_right").click()
time.sleep(3)
driver.find_element_by_id("com.xinhooa.flygram.xy:id/emoticon_edittext").send_keys("hello")
driver.find_element_by_id("com.xinhooa.flygram.xy:id/emoticon_sendbutton").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/iv_back").click()
driver.find_element_by_id("com.xinhooa.flygram.xy:id/iv_chat_nor").click()
time.sleep(3)