当我在Headless Chrome Broswer (Webdriver + Selenium )上运行 python 脚本测试网站时,经常会出现超时错误,我发现问题是脚本通过.click()或.send_keys()方法与浏览器交互时发生的。谁能知道这是什么类型的问题?有时它工作正常,但有时我有超时错误。请给出相同的解决方案
堆栈跟踪:
15:01:48,194 root:ERROR: ERROR occurred: Message: timeout
(Session info: headless chrome=60.0.3112.101)
(Driver info: chromedriver=2.31.488763
(092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1
x86)
Traceback (most recent call last):
File "c:\autotest\x.py", line 148, in main
func(nik)
File "c:\autotest\lib\support.py", line 126, in wrapper
raise ret
File "c:\autotest\lib\support.py", line 113, in newFunc
res[0] = func(*args, **kwargs)
File "c:\autotest\testcases\1001.py", line 15, in testcase
"documents_approved ASC", generateError=True)
File "c:\autotest\lib\support.py", line 51, in wrapper
f_result = …Run Code Online (Sandbox Code Playgroud) python selenium google-chrome headless-browser selenium-webdriver
我想知道为什么会收到以下错误消息以及如何修复它:
回溯(最近一次调用):<\module> 中的文件“teste.py”,第 30 行
主要的()
文件“teste.py”,第 24 行,在主目录中
驱动程序 = connectFirefox(defineOptions())
文件“teste.py”,第 18 行,在 connectFirefox 中
驱动程序 = webdriver.Firefox(firefox_options=options)
文件“/usr/lib/python3.6/site-packages/selenium/webdriver/firefox /webdriver.py”,第 125 行,在init 中
如果 options.binary 不是 None:
AttributeError: 'Options' 对象没有属性 'binary'
我的代码:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.chrome.options import Options
def defineOptions():
options = Options()
options.add_argument("--headless")
return options
def connectChrome(options):
chromeDriverPath = "/usr/bin/chromedriver"
driver = webdriver.Chrome(chromeDriverPath, chrome_options=options)
print("Chrome Headless Browser Invoked")
return driver
def connectFirefox(options):
driver = webdriver.Firefox(firefox_options=options)
print("Firefox Headless Browser Invoked")
return …Run Code Online (Sandbox Code Playgroud) python headless-browser google-chrome-headless firefox-headless
在干净的ubuntu 18.04上无头安装chrome的整个过程中,我遇到了很多问题。github上的安装指南不足以提供干净的ubuntu 18.04
以下是一些错误和解答/解决方案,用于设置无头chrome来替代phantomjs。
错误1
(node:23835) UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install"
at Launcher.launch owlcommand.com /puppeteer/node_modules/puppeteer/lib/Launcher.js:112:15)
at <anonymous>
(node:23835) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23835) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js …Run Code Online (Sandbox Code Playgroud) 我想在 puppeteer 标头中传递身份验证令牌(JWT),以便在我的应用程序中使用无头 chrome 的 pdf 视图?我们使用 react 作为我们的前端 UI。并且使用 puppeteer 我们能够生成 pdf,但是我们需要使用 JWT 授权的 pdf 链接我们如何在标头中传递 jwt,puppeteer 是否支持标头中的 Auth 令牌?请帮忙。
谢谢
我正在将我的脚本从Watir升级到Watir-Webdriver,我想知道如何利用无头浏览器测试和网格测试.我已经对它进行了一些研究但是我的来源似乎没有得到证实,现在教程非常薄,所以有人做过无头浏览或网格测试吗?你是如何实现它的,你学到了什么,你希望你知道什么时候开始?
我正在研究XP和MS Server '03 VM机器.如果我在此方面取得进展,我会尝试用信息更新问题.
你们有没有人知道.NET的无头webkit包装器?
我看过WebKitDotNet,但似乎无法在无头模式下工作.
当我运行我的测试套装时,我发现间歇性的一些文本将会持续很长时间(15分钟到半小时),PhantomJS会不断报告:
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting NOW
Asynchronous Sessions cleanup phase starting …Run Code Online (Sandbox Code Playgroud) 我正在按照本教程来配置Xvfb无头地运行firefox.
http://www.alittlemadness.com/2008/03/05/running-selenium-headless/
我现在在docker镜像(ubuntu:latest)中运行这些命令,看看我是否可以在创建容器之前正确设置我的配置.
我正在坚持运行这个命令:
Xvfb :99 -ac
Run Code Online (Sandbox Code Playgroud)
运行命令后出现这些错误:
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension SECURITY
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in …Run Code Online (Sandbox Code Playgroud) 我有一个希望是简单的任务,但是它将需要精通CefSharp的人员来解决。
我有一个要从中检索HTML的URL。问题在于此特定的url实际上并未在GET上分发页面。相反,它将大量Javascript推送到浏览器,然后浏览器执行并生成实际的呈现页面。这意味着涉及HttpWebRequest并且HttpWebResponse不会起作用的常规方法。
我研究了许多不同的“无头”选项,由于多种原因,我认为最能满足我的需求的选项是CefSharp.Offscreen。但是我对这件事的运作方式一无所知。我看到有几个事件可以订阅,还有一些配置选项,但是我不需要嵌入式浏览器之类的东西。
我真正需要的是一种执行以下操作(伪代码)的方法:
string html = CefSharp.Get(url);
Run Code Online (Sandbox Code Playgroud)
订阅事件没有问题,如果那是等待Javascript执行并生成呈现页面所需的条件。
我们正在构建一个Ionic混合应用程序,并实施了由CI系统运行的自动化E2E测试。所有这些测试都一直正常工作,直到我们在“ app.module”中实现APP_INITIALIZE才能在初始化之前获取浏览器语言。
这是我们的APP_INITIALIZE实现的肮脏代码:
-app.module.ts
export function configurateLocaleData(dynamicRegisterLocaleService: DynamicRegisterLocaleService): () => Promise<any> {
return () => dynamicRegisterLocaleService.configurateLocaleData();
}
...
providers: [
...
{
provide: APP_INITIALIZER,
useFactory: configurateLocaleData,
deps: [ DynamicRegisterLocaleService ],
multi: true
}
...
Run Code Online (Sandbox Code Playgroud)
-dynamic-register-locale.service.ts
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {AppConfig} from "../app.constants";
import {DateLocaleService} from "./dateLocale.service";
import {registerLocaleData} from "@angular/common";
@Injectable()
export class DynamicRegisterLocaleService {
constructor(private httpClient: HttpClient) {
}
public configurateLocaleData(): Promise<any> {
let currentLang = DateLocaleService.getLanguage();
return this.httpClient.get("../assets/locales/" + currentLang + ".js", {responseType: …Run Code Online (Sandbox Code Playgroud) chromium headless-browser protractor ionic-framework angular