python #Internet窗口中称为“这是WebDriver服务器的初始起始页"的描述.不能再处理了 [英] python #The description in the internet window called "This is the initial start page for the WebDriver server." can not be processed any more

查看:285
本文介绍了python #Internet窗口中称为“这是WebDriver服务器的初始起始页"的描述.不能再处理了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import os
import time
import  random
import  webbrowser
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.INTERNETEXPLORER
caps['ignoreProtectedModeSettings'] = True
binary = 'C:/Users/lee/Documents/IEDriverServer.exe'
browser = webdriver. Ie (binary)
browser.set_window_size(533,533)
browser.get('https://www.naver.com/')
time.sleep(10)
browser.quit()

推荐答案

几点:

  1. 仅保留必需的imports.删除不需要的imports,以简化操作.
  2. 需要格外小心,因为 Python spaces indents 敏感.
  3. 要提及OS路径,请使用转义的反斜杠(\\)或使用单个前斜杠(/)以及原始的(r)开关.
  4. 这是您自己的工作代码,但有一些细微的调整:

  1. Keep the required imports only. Remove the unwanted imports to keep things simpler.
  2. Need to be careful with extra spaces as Python is sensitive to spaces and indents.
  3. To mention OS paths either use escaped back slashes (\\) or use single front slashes (/) along with the raw (r) switch.
  4. Here is your own working code with some minor tweaks:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time

cap = DesiredCapabilities().INTERNETEXPLORER
cap['ignoreProtectedModeSettings'] = True
browser = webdriver.Ie(capabilities=cap, executable_path="C:\\Utility\\BrowserDrivers\\IEDriverServer.exe")
browser.get('https://www.naver.com/')
browser.set_window_size(533,533)
time.sleep(10)
browser.quit()

更新

由于看到的错误为 WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode set ,请按照以下步骤进行测试:

Update

As you are seeing the error as WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode set, follow the steps below and execute your tests :

  • 在Windows Vista或Windows 7的IE 7或更高版本上,必须将每个区域的保护模式设置设为相同的值.该值可以打开或关闭,只要每个区域都相同即可.要设置保护模式设置,请从工具"菜单中选择"Internet选项...",然后单击安全性"选项卡.对于每个区域,选项卡底部都会有一个标记为启用保护模式"的复选框.
  • 此外,对于IE 10及更高版本,必须禁用增强保护模式".在"Internet选项"对话框的高级"选项卡中找到此选项.
  • 浏览器的缩放级别必须设置为100%,以便可以将本地鼠标事件设置为正确的坐标.
  • 对于Windows 10,您还需要在显示设置中将更改文本,应用程序和其他项目的大小"设置为100%.

这篇关于python #Internet窗口中称为“这是WebDriver服务器的初始起始页"的描述.不能再处理了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆