---
title: "How to run single selenium test case in two different nodes"
author: "jerome_wang"
date: "2015-08-06T16:07:59Z"
tags: []
categories: ["行业应用"]
slug: "how-to-run-single-selenium-test-case-in-two-different-nodes"
draft: false
lastmod: "2015-08-06T16:07:59Z"
id: 2233308
url: "https://jerome-wang.iteye.com/blog/2233308"
---

转自

http://stackoverflow.com/questions/31023861/how-to-run-single-selenium-test-case-in-two-different-nodes

实测通过

前提准备：

1.请参考 [selenium + testng + grid 例子](/admin/blogs/2231619 "selenium + testng + grid 例子") + Jenkins 集成selenium grid （Jenkins 配置 网上 一大堆）

2.集成到jenkins,当ant的build.xml base.dir使用相对路径时,testng 产生报告可能会有问题 要修改下testng-result.xsl的absolute-path如下

![](http://dl2.iteye.com/upload/attachment/0110/7491/9fa8b32b-923d-307e-b1b8-6438121f7caa.png)  
 实战代码

1.初始化Driver

![](http://dl2.iteye.com/upload/attachment/0110/7493/494e5600-4fcf-3b74-8101-2ebbc4b52af8.png)  
 2.测试代码

![](http://dl2.iteye.com/upload/attachment/0110/7495/909a0769-588f-3041-9802-afae22883834.png)  
 3.testng .xml配置

![](http://dl2.iteye.com/upload/attachment/0110/7497/a6334552-ad19-3911-b6c1-7bde0207ff94.png)  
 4.ant build.xml

![](http://dl2.iteye.com/upload/attachment/0110/7499/5c635746-08cc-3211-bf81-576400076fb2.png)