Selenium GRID测试执行

时间:2017-07-21 13:47:19

标签: java selenium grid

我正在努力运行我的Selenium测试而不是本地但是在网格中。 我以为我做得很好,但是我不能让它跑。 HUB和NODE已启动并运行(从CMD开始),我正在使用正确的IP地址。 请让我知道我做错了什么!你认为这可能是代理问题吗?

问候阿诺(来自德国的学生)

// Import all the stuff I need


public class MpreisScreenshot_ID {

private String baseUrl;

  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @BeforeClass(alwaysRun = true)
  public void setUp() throws Exception {


    String requiredBrowser = "firefox";


    }
    //the "if" underneath is just for a selection (to make it better to read 
   // I  deleted the others)

     if (requiredBrowser == "firefox")
    {  
    DesiredCapabilities capabilityFirefox = DesiredCapabilities.firefox();
        capabilityFirefox.setBrowserName("firefox");
        capabilityFirefox.setVersion("54");
        WebDriver driver= new RemoteWebDriver(new 
URL("http://***.***.***.**:4445/grid/register"),capabilityFirefox); 
    } 




    baseUrl = "http://*****/****";
  //  driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
  }

WebDriver driver;


@Test
public void captureScreenshot() throws Exception 
{ 
//Start of Selenium test

// Maximize the browser

driver.manage().window().maximize();

// deleted all the steps




 @AfterMethod
 public void tearDown(ITestResult result)
 {

 // Test failing or Passing?
 if(ITestResult.FAILURE==result.getStatus())
 { 
try 
{
// Create reference of TakesScreenshot



TakesScreenshot ts=(TakesScreenshot)driver;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String uhrzeit= sdf.format(timestamp);
// Call method to capture screenshot
File source=ts.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(source, new File("D:\\DATA\\Selenium\\TestNG-
 Screenshots\\"+result.getName()+uhrzeit+".png"));

System.out.println("Screenshot taken");

} 
catch (Exception e)
{

System.out.println("Exception while taking screenshot "+e.getMessage());
} 



}
// close application
driver.quit();
}
}

1 个答案:

答案 0 :(得分:0)

检查您的网址,通常Selenium Hub的默认端口是4444,也请尝试以下操作:

http://youripaddress:4444/wd/hub/