如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
本镜像提供Selenium Grid Standalone,能够在Kubernetes集群中动态创建浏览器会话作为Kubernetes Jobs,支持远程运行WebDriver测试。
kubectl命令行工具配置完成1. 创建ConfigMap配置
ConfigMap用于存储浏览器镜像与能力映射关系,示例配置:
yaml# configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: selenium-kubernetes-config data: kubernetes.toml: | [kubernetes] configs = [ "selenium/standalone-chrome:4.41.0-20260222", '{"browserName": "chrome", "platformName": "linux"}', "selenium/standalone-firefox:4.41.0-20260222", '{"browserName": "firefox", "platformName": "linux"}', "selenium/standalone-edge:4.41.0-20260222", '{"browserName": "MicrosoftEdge", "platformName": "linux"}' ]
应用配置:
bashkubectl apply -f configmap.yaml
2. 部署Standalone服务
创建Deployment和Service,示例配置:
yaml# standalone-kubernetes.yaml apiVersion: apps/v1 kind: Deployment metadata: name: selenium-standalone-kubernetes labels: app: selenium-standalone-kubernetes se/component: standalone spec: replicas: 1 selector: matchLabels: app: selenium-standalone-kubernetes template: metadata: labels: app: selenium-standalone-kubernetes se/component: standalone spec: serviceAccountName: selenium-node terminationGracePeriodSeconds: 300 containers: - name: selenium-standalone-kubernetes image: selenium/standalone-kubernetes:4.41.0-20260222 ports: - containerPort: 4444 env: - name: SE_SESSION_REQUEST_TIMEOUT value: "600" - name: SE_SESSION_RETRY_INTERVAL value: "15" - name: SE_ROUTER_USERNAME value: "admin" - name: SE_ROUTER_PASSWORD value: "admin" - name: SE_NODE_SESSION_TIMEOUT value: "600" - name: SE_DYNAMIC_OVERRIDE_MAX_SESSIONS value: "true" - name: SE_DYNAMIC_MAX_SESSIONS value: "10" resources: requests: memory: "512Mi" cpu: "0.5" limits: memory: "2Gi" cpu: "1" livenessProbe: exec: command: - /bin/sh - -c - curl -G --fail --silent -u ${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD} localhost:4444/status initialDelaySeconds: 30 timeoutSeconds: 5 readinessProbe: httpGet: path: /readyz port: 4444 initialDelaySeconds: 30 timeoutSeconds: 5 volumeMounts: - name: selenium-config mountPath: /opt/selenium/kubernetes.toml subPath: kubernetes.toml readOnly: true - name: session-assets mountPath: /opt/selenium/assets volumes: - name: selenium-config configMap: name: selenium-kubernetes-config - name: session-assets persistentVolumeClaim: claimName: selenium-assets --- apiVersion: v1 kind: Service metadata: name: selenium-standalone-kubernetes spec: selector: app: selenium-standalone-kubernetes ports: - name: web port: 4444 targetPort: 4444 nodePort: 30444 type: NodePort
应用部署:
bashkubectl apply -f standalone-kubernetes.yaml
3. 配置测试脚本
将WebDriver测试指向Grid服务地址:
http://admin:admin@localhost:30444
4. 访问Grid UI(可选)
通过以下地址访问Grid管理界面:
http://admin:admin@localhost/ui/
| 环境变量 | 描述 | 示例值 |
|---|---|---|
| SE_SESSION_REQUEST_TIMEOUT | 会话请求超时时间(秒) | "600" |
| SE_SESSION_RETRY_INTERVAL | 会话请求重试间隔(秒) | "15" |
| SE_ROUTER_USERNAME | Grid路由用户名 | "admin" |
| SE_ROUTER_PASSWORD | Grid路由密码 | "admin" |
| SE_NODE_SESSION_TIMEOUT | 节点会话超时时间(秒) | "600" |
| SE_DYNAMIC_OVERRIDE_MAX_SESSIONS | 是否覆盖最大会话数配置 | "true" |
| SE_DYNAMIC_MAX_SESSIONS | 动态最大会话数 | "10" |
镜像标签遵循以下结构:
selenium/standalone-kubernetes-<Major>.<Minor>.<Patch>-<YYYYMMDD>
4:最新4.x版本4.41:最新4.41.x版本4.41.0:指定4.41.0版本4.41.0-20260222:完整版本(推荐用于版本固定)更多详细信息请参考Docker-Selenium项目的https://github.com/SeleniumHQ/docker-selenium%E3%80%82
本项目基于https://raw.githubusercontent.com/SeleniumHQ/selenium/trunk/LICENSE%E5%BC%80%E6%BA%90%E5%8D%8F%E8%AE%AE%E3%80%82
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务