Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package github;
  2.  
  3. import org.apache.commons.io.FileUtils;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebDriver;
  6. import org.openqa.selenium.chrome.ChromeDriver;
  7. import org.openqa.selenium.chrome.ChromeOptions;
  8. import org.openqa.selenium.support.ui.ExpectedConditions;
  9. import org.openqa.selenium.support.ui.WebDriverWait;
  10. import org.testng.annotations.AfterMethod;
  11. import org.testng.annotations.BeforeMethod;
  12. import org.testng.annotations.Test;
  13.  
  14. public class GitHub4477 {
  15.  
  16. private WebDriver driver;
  17.  
  18. @BeforeMethod
  19. public void setUp() throws Exception {
  20. ChromeOptions chromeOptions = new ChromeOptions();
  21. //todo Change your chrome driver path
  22. System.setProperty("webdriver.chrome.driver", Thread.currentThread().getContextClassLoader()
  23. .getResource("chromedriver.exe").getFile());
  24. chromeOptions.addArguments("--headless");
  25. driver = new ChromeDriver(chromeOptions);
  26. }
  27.  
  28. @Test
  29. public void testIssue4477() throws Exception {
  30. // todo change it to test html page
  31. driver.get("file:///C:/Users/nitish/Desktop/test.html");
  32. WebDriverWait wait = new WebDriverWait(driver, 10);
  33. wait.until(
  34. ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='form']/p[1]/label")));
  35. System.out.println(
  36. "Label text : " + driver.findElement(By.xpath("//*[@id='form']/p[1]/label")).getText());
  37. }
  38.  
  39. @AfterMethod
  40. public void tearDown() throws Exception {
  41. driver.close();
  42. driver.quit();
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement