小编CS1*_*S10的帖子

无法在Selenium中将click()与移动设备仿真的chromedriver一起使用

我正在尝试使用移动模拟chrome浏览器测试内部Web应用程序的登录过程。我正在使用Python 3.6.4。

它会按名称查找元素,但不会单击它!

这是我的代码:

from selenium import webdriver
enter code herefrom selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import time

mobile_emulation = {

    "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },

    "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" }

chrome_options = Options()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome(chrome_options = chrome_options)

driver.get("https://internalweburlhere")
elem = driver.find_element_by_id("txtEmailAddress")
elem.clear()
elem.send_keys("Username")
elem = driver.find_element_by_id("txtPassword")
elem.send_keys("1234")
print("Password Entered")
driver.find_element_by_id("btnSignIn").click()
print("Logged In")
Run Code Online (Sandbox Code Playgroud)

这是网站资源:

<div …
Run Code Online (Sandbox Code Playgroud)

python selenium android infragistics selenium-chromedriver

5
推荐指数
1
解决办法
1079
查看次数