selenium独立与CORS
我目前正在通过nodejs与selenium独立使用webdriver io,这一切工作正常,直到我尝试做基于CORS的请求。 我目前使用Firefox作为testing浏览器,并且由于CORS请求到另一个域而引发错误。
服务器configuration为返回CORS的正确标题,XHR对象configuration为允许CORS。 我知道这些工作,因为当我手动使用该网站通过Firefox /铬的工作正常,但是当我testing它似乎炸毁了,这使我困惑,因为服务器和客户端configuration为CORS,并没有涉及当前testing的HTTPS。
那么为了让CORS在testing浏览器中工作,还有什么特别的事情要做吗? 我知道Selenium以自己的configuration文件启动浏览器,但是在configuration浏览器设置时找不到与cors有关的任何细节,也找不到与CORS实现相关的任何dependentFeatures。
如果能提供答案,我很乐意提供更多信息。
首先,CORS正在你的浏览器中工作,但是由于Selenium的工作原理以及你的应用程序逻辑,它们可能会相互冲突。
我build议只将selenium的CORS检查closures。
对于Chrome,通过在function中添加“disable-web-security”可以轻松closuresCORS检查。 对于Firefox,它将是“security.fileuri.strict_origin_policy”首选项(不是能力)。 例如使用https://github.com/saadtazi/firefox-profile-js
var FirefoxProfile = require('firefox-profile'), webdriverjs = require('webdriverjs'); var fp = new FirefoxProfile(); fp.setPreference("security.fileuri.strict_origin_policy", false); fp.encoded(function(prof) { var client = webdriverjs.remote({ desiredCapabilities: { browserName: 'firefox', firefox_profile: prof } }); client .init() .url('http://stackoverflow.com/') .end(); });
- HTTP响应头中'Allow'和'Access-Control-Allow-Methods'之间的区别?
- angular度选项HTTP预检“同一域”?
- 仅在Chrome中使用超慢速预检选项
- Angular / Node / Express / Passport跨域问题 – 启用CORS Passport Facebook身份validation
- 如何使用提取与application / json的内容types发布
- 在angular度全堆发生器上启用CORS?
- 使用CORS请求设置Cookie
- 在使用AngularJS发送GET请求时,无法从WebStorm IDE执行“打开”无效URL
- AS3能够识别头部的CORS权限吗?