[英]Selenium GRID Test execution
我正在努力在本地而不是本地運行Selenium Test。 我以為我做的很好,但我沒有讓它運行。 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();
}
}
檢查您的URL,通常Selenium Hub的默認端口為4444,也嘗試以下操作:
http://youripaddress:4444/wd/hub/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.