82 lines
2.2 KiB
Java
82 lines
2.2 KiB
Java
package com.bayer.edam;
|
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import org.junit.After;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.openqa.selenium.Alert;
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.NoAlertPresentException;
|
|
import org.openqa.selenium.NoSuchElementException;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
|
|
|
public class ToolboxVideoExporter {
|
|
private WebDriver driver;
|
|
private String baseUrl;
|
|
private boolean acceptNextAlert = true;
|
|
private StringBuffer verificationErrors = new StringBuffer();
|
|
|
|
@Before
|
|
public void setUp() throws Exception {
|
|
System.setProperty("webdriver.gecko.driver", "F:\\Toolbox\\geckodriver.exe");
|
|
driver = new FirefoxDriver();
|
|
baseUrl = "https://bayertoolbox.com/";
|
|
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
|
}
|
|
|
|
@Test
|
|
public void testCase() throws Exception {
|
|
driver.get(baseUrl + "/Assets/AssetDetailNational.aspx?AssetID=22936");
|
|
driver.findElement(By.cssSelector("#MainContent_aDownload > strong")).click();
|
|
driver.findElement(By.cssSelector("#MainContent_aDownload > strong")).click();
|
|
driver.findElement(By.id("MainContent_btnDownloadOk")).click();
|
|
driver.findElement(By.id("MainContent_btnDownloadOk")).click();
|
|
}
|
|
|
|
@After
|
|
public void tearDown() throws Exception {
|
|
driver.quit();
|
|
String verificationErrorString = verificationErrors.toString();
|
|
if (!"".equals(verificationErrorString)) {
|
|
fail(verificationErrorString);
|
|
}
|
|
}
|
|
|
|
private boolean isElementPresent(By by) {
|
|
try {
|
|
driver.findElement(by);
|
|
return true;
|
|
} catch (NoSuchElementException e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private boolean isAlertPresent() {
|
|
try {
|
|
driver.switchTo().alert();
|
|
return true;
|
|
} catch (NoAlertPresentException e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private String closeAlertAndGetItsText() {
|
|
try {
|
|
Alert alert = driver.switchTo().alert();
|
|
String alertText = alert.getText();
|
|
if (acceptNextAlert) {
|
|
alert.accept();
|
|
} else {
|
|
alert.dismiss();
|
|
}
|
|
return alertText;
|
|
} finally {
|
|
acceptNextAlert = true;
|
|
}
|
|
}
|
|
}
|