我只是为Selenium WebDriver(又名Selenium 2)为无头测试创建了一个简单的maven项目.我在pom.xml中添加了PhantomJS驱动程序依赖项和其他依赖项:
<dependency>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但它得到了错误:
java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at jp.co.skygate.home.HomePageLogin.setUp(HomePageLogin.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
Run Code Online (Sandbox Code Playgroud)
只是从pom.xml中删除PhantomJS依赖项解决了问题并且执行正常.有人可以帮我找到问题吗?
提前致谢.
我买了socsk5的代理服务器版本。在所有手册中相同的例子
const browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
defaultViewport: {...winSize},
args: [
'--proxy-server=socks5://proxyhost:8000',
'--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE proxyhost"',
],
})
Run Code Online (Sandbox Code Playgroud)
它没有为此代理指定登录密码,显然不起作用
如果你指定这个
'--proxy-server=socks5://user:password@proxyhost:8000',
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误
net::ERR_NO_SUPPORTED_PROXIES
我尝试使用https://github.com/sjitech/proxy-login-automator构建一座桥,但它也不起作用。
请提示
google-chrome headless headless-browser google-chrome-headless puppeteer
我正在尝试使用 Chrome 浏览器、Selenium 和 Java 以无头模式运行我的应用程序。但它打开一个新的 chrome 实例并开始在正常 UI 模式下运行脚本(可以看到执行情况)
代码或浏览器兼容性是否有问题。
操作系统 - Windows 10,Chrome 版本 - 85.0.4183.121
下面是我的代码 -
package XYZ;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class Test{
public static void main(String args[]) {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\TestUser\\Desktop\\SeleniumWorkspace\\ABC\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("window-size=1400,800");
options.addArguments("disable-gpu")
//options.addArguments("--headless", "--disable-gpu", "--window-size=1400,800","--ignore-certificate-errors");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com");
System.out.println(driver.getCurrentUrl());
}
}
Run Code Online (Sandbox Code Playgroud) java google-chrome headless selenium-webdriver google-chrome-headless
我想在此页面上使用 Selenium: https: //www.avis.com/en/home
如果没有无头模式,该代码一切正常:
import requests
from bs4 import BeautifulSoup
import os, sys, time
import xlwings as xw
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
from random import choice
from selenium import webdriver
from sys import platform
WAIT = 1
link = f"https://www.avis.com/en/home"
cd = '/chromedriver.exe'
options = Options()
# options.add_argument('--headless')
options.add_experimental_option ('excludeSwitches', ['enable-logging'])
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36")
driver = webdriver.Chrome (path + cd, options=options)
driver.get …Run Code Online (Sandbox Code Playgroud) [aspectj:compile {execution: default}]
Current policy properties:
mmc.sess_pe_act.block_unsigned: false
window.num_max: 5
jscan.sess_applet_act.sig_trusted: pass
file.destructive.state: disabled
jscan.sess_applet_act.block_all: false
window.num_limited: true
jscan.sess_applet_act.unsigned: instrument
mmc.sess_pe_act.action: validate
jscan.session.daemon_protocol: http
file.read.state: disabled
mmc.sess_pe_act.block_invalid: true
mmc.sess_pe_act.block_blacklisted: false
net.bind_enable: false
jscan.session.policyname: TU1DIERlZmF1bHQgUG9saWN5
mmc.sess_cab_act.block_unsigned: false
file.nondestructive.state: disabled
jscan.session.origin_uri: http://commonjar.googlecode.com/svn/trunk/mavenrepository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
mmc.sess_cab_act.action: allowall
net.connect_other: false
jscan.session.user_ipaddr: 10.1.4.91
jscan.sess_applet_act.sig_invalid: block
mmc.sess_cab_act.block_invalid: true
thread.thread_num_max: 8
jscan.sess_applet_act.sig_blacklisted: block
net.connect_src: true
thread.thread_num_limited: true
jscan.sess_applet_act.stub_out_blocked_applet: true
mmc.sess_cab_act.block_blacklisted: true
mmc.sess_pe_act.enforce_for_com_objects_only: true
jscan.session.user_name: 10.1.4.91
thread.threadgroup_create: false
file.write.state: disabled
-->> returning Frame NULL
BaseDialog: owner frame is a java.awt.Frame …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用无头gem,xvfb和capybara-webkit在ubuntu服务器CI盒上运行一套集成规范,用于无头测试.一切都在本地开发盒上运行得很漂亮,但是一旦转移到CI服务器,事情就会变得很有趣.
在规范助手中有一些代码包装:js在无头块中启用了集成规范,如下所示:
config.around(:each, :js => true) do |example|
Headless.ly &example
end
Run Code Online (Sandbox Code Playgroud)
就像我说的,这一切都适用于本地开发盒.在使用无头gem和xvfb作为同一用户进行不同项目测试的CI上,当规范需要实例化浏览器实例时,尝试运行集成规范会导致以下错误:
webkit_server:致命IO错误:客户端被杀死
我一直在试图找出可能导致该错误的原因,但是甚至找不到可能来自哪里的痕迹,或者任何其他信息来帮助调试该问题.
到目前为止,我已经检查/尝试了以下内容:
有没有人有任何想法可能导致这种情况,或者我可以寻找更多信息?我很难过.
谢谢!
我需要在无头服务器上安装chrome扩展.一种方法是使用组策略.我正在寻找其他一些方法.
对于Firefox,我只需将我的XPI(扩展名)放在profile目录/ extensions文件夹中,Firefox就会选择扩展名.我想知道对于chrome我是否可以做类似的事情.
谢谢.
我在非gui模式下使用jmeter脚本运行负载测试.
我使用以下命令以非gui模式运行JMeter,结果存储在Test.jtl文件中
sh jmeter.sh -n -t ThreadGroup.jmx -l Test.jtl
Run Code Online (Sandbox Code Playgroud)
写入Test.jtl的样本数据如下所示,不会打印响应数据.有没有办法打印响应数据,也可以通过改变jmeter脚本或以上命令?
任何帮助,将不胜感激.
1453272193899,231,HTTP Request-staging-qqq-customer1,200,OK,Thread Group two 1-6,text,true,466,231
1453272193927,227,HTTP Request-staging-TT2-customer1,503,Service Unavailable,Thread Group two 1-1,text,false,751,227
1453272193963,222,HTTP Request-staging-TT2-customer1,503,Service Unavailable,Thread Group two 1-2,text,false,604,222
1453272194026,238,HTTP Request-staging-TT1-customer1,200,OK,Thread Group two 1-3,text,true,448,238
1453272194131,233,HTTP Request-staging-qqq-customer2,200,OK,Thread Group two 1-6,text,true,466,233
Run Code Online (Sandbox Code Playgroud)
谢谢
当我使用具有以下内容的html文档(' SimplePage.html ')时
<!DOCTYPE html>
<html>
<title>Page Title</title>
<body>
This is just a simple Hello World
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Libreoffice(在Windows 7上为LibreOffice_5.1.2)会生成一个pdf文件,该文件的第一页为空白,然后不写全文-而是仅显示“ 一个简单的Hello World ”
我正在使用以下命令行
soffice.exe --headless --convert-to pdf SimplePage.html
Run Code Online (Sandbox Code Playgroud)
当我不是在无头模式下进行转换时(打开Libreoffice writer并使用“导出”,则生成的pdf是正确的。因此,我认为使用的HTML并不是问题。有人知道这个问题的原因和解决方案吗?
当我运行脚本时,出现此错误
Traceback (most recent call last):
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 992, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ishaq/AppData/Local/Programs/Python/Python36/headless.py", line 9, in <module>
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"), chrome_options=chrome_options)
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: …Run Code Online (Sandbox Code Playgroud) python selenium headless selenium-chromedriver google-chrome-headless