我正在尝试使脚本自动化。如果我手动提供数据,则脚本正在运行。但是,当我不是手动提供数据而是自动提供数据时,脚本将无法正常工作。
我试图在不手动插入数据的情况下运行脚本,但是失败了。
// url hit
driver.get("https://login.reltio.com/?clientId=reltio_ui&redirectUrl=https%3A%2F%2Fpilot.reltio.com%2Fservices%2Fsso&state=aHR0cHM6Ly9waWxvdC5yZWx0aW8uY29tL3VpL25sdnZSR0hRSEVMQVBpSi8jcH5jb20ucmVsdGlvLnBsdWdpbnMuc2VhcmNoLlNlYXJjaFBlcnNwZWN0aXZlX3d-ZzVt&tenant=nlvvRGHQHELAPiJ");
// username
driver.findElement(By.xpath("//input[@name='username']")).sendKeys("manisha.nisha@freshgravity.com");
//password
WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("password11");
//login button
driver.findElement(By.xpath(("//span[@class='jss82']"))).click();
driver.manage().timeouts().implicitlyWait(200, TimeUnit.SECONDS);
WebElement search = driver.findElement(By.xpath("//input[@type='search']"));
driver.findElement(By.xpath("//input[@type='search']")).click();
driver.findElement(By.xpath("//input[@type='search']")).sendKeys("Ope9WP1");
driver.findElement(By.xpath("//input[@type='search']")).sendKeys(Keys.ENTER);
WebElement text= driver.findElement(By.xpath("//a[contains(text(),'NCT000DEMO1')] "));
text.click();
// driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
if(text.isDisplayed()) {
File src= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src, new File("E:\\//screenshot25.png"));
System.out.println("Screenshot is taken");
}
else {
System.out.println("Screenshot not taken");
}
我期望的结果是自动的,没有任何错误。实际结果是脚本无法正确执行。