首页 新闻 会员 周边

selenuim H5自动化 button按钮点击无反应

0
[已解决问题] 解决于 2018-07-26 09:43

python3 使用pycharm在pc端使用chrome模拟手机端访问H5页面,进行登录时,button按钮点击无反应,也未报错,求解决!!

自动化运行中chrome点击其他按钮可以跳转,就是登录按钮无法点击。

button按钮是tap事件,是否jQuery要怎样去调取

mobileEmulation = {'deviceName': 'iPhone 6'}
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation', mobileEmulation)
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)
driver.find_element_by_tag_name("button").click()/driver.find_element_by_id("login").click()
sleep(10)


 

joker_you的主页 joker_you | 菜鸟二级 | 园豆:204
提问于:2018-07-25 10:09
< >
分享
最佳答案
1

链接给一个

奖励园豆:5
Masako | 小虾三级 |园豆:1893 | 2018-07-25 17:24
截图未显示出来噢:
driver
.get("http://60.255.48.13:30002/my.html")

#sleep(3)
#driver.find_element_by_tag_name("button").click()
driver.find_element_by_id("login").click()
joker_you | 园豆:204 (菜鸟二级) | 2018-07-25 17:29

@joker_you: 

应该是打开方式的问题,这个打开是无法触发点击事件,我也不清楚怎样弄成调试的那种。

找了一个大神的解决办法,测试过了,地址如下:

https://www.cnblogs.com/yoyoketang/p/7942275.html

Masako | 园豆:1893 (小虾三级) | 2018-07-25 18:14

@Masako: 非常感谢,昨天我在另外一篇文章也找到了这种解决方法,模拟手机操作行为去点击,click方法无法实现,用touch action就能点击了。

链接分享:http://www.xue63.com/toutiaojy/20171228G0NIT400.html

doc = driver.find_element_by_id("login")
TouchActions(driver).tap(doc).perform()

joker_you | 园豆:204 (菜鸟二级) | 2018-07-26 09:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册