internet-explorer-11 - IE11 Script1003:应为“}”
问题描述
适用于 Chrome 和 Firefox,但 IE11 给我以下脚本错误。
IE11 Script1003: Expected "}" 请注意我正在从 selenium 执行脚本。例如:driver.execute_script("console.log(document.title)") 如果我犯了任何错误,你能告诉我怎么办。
解决方案
尝试用IE浏览器直接访问网站,用F12开发者工具查看是否有同样的错误?
根据您的代码,我假设您正在使用带有 IE webdriver 的 python,我使用以下代码创建了一个示例,该代码在 IE 11 浏览器中运行良好。
import time
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().INTERNETEXPLORER
cap['ignoreZoomSetting'] = True
driver = webdriver.Ie("D:\\Downloads\\webdriver\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe",capabilities= cap)
driver.get("https://www.bing.com")
time.sleep(5)
driver.execute_script("document.getElementById('sb_form_q').value = 'Hi webdriver'; console.log('hello webdriver');")
print("*******************")
请尝试测试上面的代码,如果仍然不能解决问题,请发布足够的代码来重现问题,如Minimal, Complete, and Verifiable example。
推荐阅读
- reactjs - 编辑待办事项列表状态在与 axios 的反应中未正确传递
- jquery - 如何将 JSON 数组转换为 JSON 字符串 jquery
- java - 用于 5 GB 文件的 MapReduce
- go - net/http 服务器在 ab (ApacheBench) 重负载下冻结
- wordpress - 如何获取自定义帖子类型 ID
- java - maven surefire 插件没有并行执行运行器
- c++ - isalpha() 函数允许通过拉丁字母,尽管语言环境设置为俄语
- hive - 在 Hive 中,如何组合多个表以生成包含对象数组的单行?
- php - clouser函数没有在类文件中调用
- azure-active-directory - 使用图形 api 查询第三方 azure AD 的 AD 应用程序注册或企业应用程序?