Skip to content

Commit

Permalink
ChromeOptions and cookie management
Browse files Browse the repository at this point in the history
  • Loading branch information
angiejones committed Jul 11, 2019
1 parent c10914a commit acec262
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions webdriver_java/src/test/java/base/BaseTests.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package base;

import com.google.common.io.Files;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.testng.ITestResult;
import org.testng.annotations.AfterClass;
Expand All @@ -26,9 +27,10 @@ public class BaseTests {
@BeforeClass
public void setUp(){
System.setProperty("webdriver.chrome.driver", "resources/chromedriver");
driver = new EventFiringWebDriver(new ChromeDriver());
driver = new EventFiringWebDriver(new ChromeDriver(getChromeOptions()));
driver.register(new EventReporter());
goHome();
//setCookie();
}

@BeforeMethod
Expand Down Expand Up @@ -59,4 +61,18 @@ public void recordFailure(ITestResult result){
public WindowManager getWindowManager(){
return new WindowManager(driver);
}

private ChromeOptions getChromeOptions(){
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
//options.setHeadless(true);
return options;
}

private void setCookie(){
Cookie cookie = new Cookie.Builder("tau", "123")
.domain("the-internet.herokuapp.com")
.build();
driver.manage().addCookie(cookie);
}
}

0 comments on commit acec262

Please sign in to comment.