我正在 Microsoft Edge 上调试应用程序,我想知道是否有办法保留网络日志?
在页面重定向到另一个请求之前,我需要检查一个请求。
该项目的目标是使用 selenium-python 使用 Microsoft Edge 浏览器自动检查站点 我从此链接下载了 Edge Legacy 的 WebDriver ,我选择了最新版本 17134 提取它,没有任何问题,现在可以说我想访问facebook 使用 geckodriver 以自动化的方式与 firefox 一起使用
使用 selenium 的 Firefox 代码示例
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
# setting up headless option for faster execution
options = Options()
options.headless = True
browser = (webdriver.Firefox(options=options))
browser.get('https://www.facebook.com/')
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用 Windows 10 中内置的 Microsoft Edge 时,出现属性错误
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.edge.options import Options
options = Options()
options.headless = True …Run Code Online (Sandbox Code Playgroud) 我想检测浏览器是否为 chrome。我遇到了很多答案,但对于歌剧和新版本的边缘,所有答案都为真。我想知道您是否有检测浏览器是否为 chrome 的最佳方法
[编辑] 到目前为止我测试过的返回 true 的代码:
//Test 1 => Opera and edge returns true
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
// Test 2 => return false for chrome latest version
var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
//Test 3 => same as test 1
var is_chrome = /chrome/i.test( navigator.userAgent );Run Code Online (Sandbox Code Playgroud)
我想禁用浏览器的后退按钮。我尝试过一些 javascript 代码来实现相同的功能。但这些代码并没有满足我的要求。它可以在 Firefox 中运行,但不能在 Chrome 和 Edge 中运行。有时这三个都可以工作,但随机工作和不工作。
任何人都可以与我分享该脚本,该脚本可以在所有浏览器中禁用后退按钮,而不会出现随机行为等缺陷。
这里我展示了一些我尝试过的脚本
history.pushState(null, null, window.location.href);
history.back();
window.onpopstate = () => history.forward();
history.pushState(null, null, location.href);
history.back();
history.forward();
window.onpopstate = function () { history.go(1); };
Run Code Online (Sandbox Code Playgroud)