开发者社区> 问答> 正文

selenium模块Chrome无头模式问题

下面这段代码使用正常模式能定位到输入框,为什么使用无头模式就定位不到输入框了呢?
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = 'http://ehall.jit.edu.cn/new/index.html'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
browser = webdriver.Chrome('D:/Python36-32/Scripts/chromedriver.exe', chrome_options=chrome_options)

browser = webdriver.Chrome('D:/Python36-32/Scripts/chromedriver.exe')

browser.get(url)
wait = WebDriverWait(browser, 15)
input_denglu = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'amp-no-login-zh')))
input_denglu.click()
input_username = wait.until(EC.presence_of_element_located((By.ID, 'username')))
input_username.clear()
input_username.send_keys(user)
input_password = wait.until(EC.presence_of_element_located((By.ID, 'password')))
input_password.clear()
input_password.send_keys(pad)

展开
收起
佳佳233 2018-09-09 21:30:32 7023 0
1 条回答
写回答
取消 提交回答
  • 这个可以查看开发文档,寻求帮助。

    2019-07-17 23:04:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
WEB浏览器中即将发生的安全变化 立即下载
基于浏览器的实时构建探索之路 立即下载
基于浏览器的实时构建探索之路--玄寂 立即下载