数码之家

 找回密码
 立即注册

QQ登录

只需一步,快速开始

微信登录

微信扫一扫,快速登录

搜索

Selenium Standalone |work| Page

#!/bin/bash JAR="selenium-server-4.27.0.jar" if [ ! -f "$JAR" ]; then wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.27.0/$JAR fi Start server echo "Starting Selenium Standalone on http://localhost:4444" java -jar $JAR standalone --selenium-manager true Access UI at http://localhost:4444/ui

driver.get("https://www.google.com") print(driver.title) driver.quit() import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.net.URL; public class Test public static void main(String[] args) throws Exception ChromeOptions options = new ChromeOptions(); WebDriver driver = new RemoteWebDriver( new URL("http://localhost:4444"), options ); selenium standalone

driver.get("https://www.google.com"); System.out.println(driver.getTitle()); driver.quit(); selenium standalone

# Run Selenium Standalone with Chrome docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:latest Run with Firefox docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:latest Access VNC at http://localhost:7900 (password: secret) Advanced Configuration Starting with Custom Drivers # Chrome java -jar selenium-server-4.27.0.jar standalone \ --selenium-manager true \ --driver-implementation chrome Firefox java -jar selenium-server-4.27.0.jar standalone --selenium-manager true --driver-implementation firefox With driver path java -jar selenium-server-4.27.0.jar standalone --driver-chrome-driver /path/to/chromedriver Configuration File Example Create config.toml : selenium standalone

Run with config:

[[node]] driver-implementation = "chrome" max-sessions = 5

[[node]] driver-implementation = "firefox" max-sessions = 3

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

selenium standalone

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2025-12-14 16:13 , Processed in 0.140400 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz!

© 2006-2025 MyDigit.Net

快速回复 返回顶部 返回列表