com.codeborne.selenide.Configuration Java Examples

The following examples show how to use com.codeborne.selenide.Configuration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JustTestLahConfiguration.java    From justtestlah with Apache License 2.0 6 votes vote down vote up
/** Set the correct {@link org.openqa.selenium.WebDriver}. */
public synchronized void initWebDriver() {
  // for web and local testing the Selenide default behavior is sufficient
  System.setProperty("browser", browser);
  // not thread-safe!
  Configuration.headless = headless;
  Platform platform = getPlatform();
  if (platform.equals(Platform.ANDROID)) {
    WebDriverRunner.setWebDriver(webDriverBuilder.getAndroidDriver());
  } else if (platform.equals(Platform.IOS)) {
    WebDriverRunner.setWebDriver(webDriverBuilder.getIOsDriver());
  } else if (platform.equals(Platform.WEB)) {
    if (cloudProvider.equals("browserstack")) {
      WebDriverRunner.setWebDriver(webDriverBuilder.getWebDriver());
      open(baseUrl);
    } else {
      open(baseUrl);
      WebDriverRunner.setWebDriver(webDriverBuilder.getWebDriver());
    }
  }
  WebDriver driver = WebDriverRunner.getWebDriver();
  if (driver instanceof TakesScreenshot) {
    ocr.setDriver(driver);
  }
}
 
Example #2
Source File: UseSoftAssertions.java    From neodymium-library with MIT License 6 votes vote down vote up
@Test(expected = ElementNotFound.class)
public void validateSoftAssertion()
{
    Neodymium.softAssertions(true);
    Selenide.open("https://blog.xceptance.com/");

    Assert.assertEquals(Configuration.assertionMode, AssertionMode.SOFT);
    $("#notFound1").should(exist);
    $("#notFound2").should(exist);
    $("#masthead .search-toggle").click();
    $("#notFound3").should(exist);
    $("#notFound4").click();

    // This should not be called since
    throw new NullPointerException();
}
 
Example #3
Source File: SelenideMultiTest.java    From healenium-web with Apache License 2.0 5 votes vote down vote up
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Configuration.timeout = 15000;

    WebDriverManager.chromedriver().setup();
    capabilities.setBrowserName("chrome");
    ChromeOptions options = new ChromeOptions();
    options.setHeadless(true);
    options.merge(capabilities);
    WebDriver wd = new ChromeDriver(options);
    return SelfHealingDriver.create(wd);
}
 
Example #4
Source File: DownloadTestWithDockerAndProxy.java    From testcontainers with MIT License 5 votes vote down vote up
@After
public void tearDown() {
    proxyServer.shutdown();
    WebDriverRunner.closeWebDriver();
    Configuration.fileDownload = HTTPGET;
    Configuration.proxyEnabled = false;
    Configuration.proxyHost = null;
    Configuration.proxyPort = 0;
}
 
Example #5
Source File: DownloadTestWithDockerAndProxy.java    From testcontainers with MIT License 5 votes vote down vote up
@Before
public void setUp() {
    Configuration.proxyHost = "host.testcontainers.internal";
    Configuration.proxyPort = proxyPort;
    Configuration.proxyEnabled = true;
    Configuration.fileDownload = PROXY;

    proxyServer = new SelenideProxyServer(new StaticConfig(), null);
    proxyServer.start();

    RemoteWebDriver driver = chrome.getWebDriver();
    WebDriverRunner.setWebDriver(driver, proxyServer);
}
 
Example #6
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Configuration.browserSize = String.format("%sx%s", loadSystemPropertyOrDefault(WINDOW_WIDTH, DEFAULT_WIDTH),
            loadSystemPropertyOrDefault(WINDOW_HEIGHT, DEFAULT_HEIGHT));
    String expectedBrowser = loadSystemPropertyOrDefault(BROWSER, CHROME);
    String remoteUrl = loadSystemPropertyOrDefault(REMOTE_URL, LOCAL);
    BlackList blackList = new BlackList();
    boolean isProxyMode = loadSystemPropertyOrDefault(PROXY, false);
    if (isProxyMode) {
        enableProxy(capabilities);
    }

    log.info("remoteUrl=" + remoteUrl + " expectedBrowser= " + expectedBrowser + " BROWSER_VERSION=" + System.getProperty(CapabilityType.BROWSER_VERSION));

    switch (expectedBrowser.toLowerCase()) {
        case (FIREFOX):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createFirefoxDriver(capabilities) : getRemoteDriver(getFirefoxDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (MOBILE_DRIVER):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? new ChromeDriver(getMobileChromeOptions(capabilities)) : getRemoteDriver(getMobileChromeOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (OPERA):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createOperaDriver(capabilities) : getRemoteDriver(getOperaRemoteDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (SAFARI):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createSafariDriver(capabilities) : getRemoteDriver(getSafariDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (INTERNET_EXPLORER):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createIEDriver(capabilities) : getRemoteDriver(getIEDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (IE):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createIEDriver(capabilities) : getRemoteDriver(getIEDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        case (EDGE):
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createEdgeDriver(capabilities) : getRemoteDriver(getEdgeDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());
        default:
            return LOCAL.equalsIgnoreCase(remoteUrl) ? createChromeDriver(capabilities) : getRemoteDriver(getChromeDriverOptions(capabilities), remoteUrl, blackList.getBlacklistEntries());

    }
}
 
Example #7
Source File: DefaultSelenideConfiguration.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void test2() throws Exception
{
    Assert.assertEquals(3000, Configuration.timeout);
    Assert.assertEquals(false, Configuration.fastSetValue);
    Assert.assertEquals(false, Configuration.clickViaJs);
}
 
Example #8
Source File: DefaultSelenideConfiguration.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void test1() throws Exception
{
    Neodymium.timeout(1234);
    Assert.assertEquals(1234, Configuration.timeout);

    Neodymium.fastSetValue(true);
    Assert.assertEquals(true, Configuration.fastSetValue);

    Neodymium.clickViaJs(true);
    Assert.assertEquals(true, Configuration.clickViaJs);
}
 
Example #9
Source File: SelenideConfigurationShortcuts.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void validateTimeout()
{
    Assert.assertEquals(Configuration.timeout, 3000);

    Neodymium.timeout(1000);
    Assert.assertEquals(Configuration.timeout, 1000);

    Neodymium.timeout(2000);
    Assert.assertEquals(Configuration.timeout, 2000);
}
 
Example #10
Source File: SelenideConfigurationShortcuts.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void validateFastSetValue()
{
    Assert.assertEquals(Configuration.fastSetValue, false);

    Neodymium.fastSetValue(true);
    Assert.assertEquals(Configuration.fastSetValue, true);

    Neodymium.fastSetValue(false);
    Assert.assertEquals(Configuration.fastSetValue, false);
}
 
Example #11
Source File: SelenideConfigurationShortcuts.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void validateClickViaJs()
{
    Assert.assertEquals(Configuration.clickViaJs, false);

    Neodymium.clickViaJs(true);
    Assert.assertEquals(Configuration.clickViaJs, true);

    Neodymium.clickViaJs(false);
    Assert.assertEquals(Configuration.clickViaJs, false);
}
 
Example #12
Source File: SelenideConfigurationShortcuts.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void validateSoftAssertion()
{
    Assert.assertEquals(Configuration.assertionMode, AssertionMode.STRICT);

    Neodymium.softAssertions(true);
    Assert.assertEquals(Configuration.assertionMode, AssertionMode.SOFT);

    Neodymium.softAssertions(false);
    Assert.assertEquals(Configuration.assertionMode, AssertionMode.STRICT);
}
 
Example #13
Source File: LambdaBaseTest.java    From lambda-selenium with MIT License 5 votes vote down vote up
@BeforeClass
public static void baseTestBeforeClass() {
    Configuration.browser = "chrome";
    Configuration.reopenBrowserOnFail = false;

    if (EnvironmentDetector.inLambda()) {
        WebDriverRunner.webdriverContainer = new LambdaWebDriverThreadLocalContainer();
    }
}
 
Example #14
Source File: BaseTest.java    From selenide-appium with MIT License 4 votes vote down vote up
@Before
public void setUp() {
  Configuration.startMaximized = false;
  Configuration.browserSize = null;
  Configuration.browser = AndroidDriverProvider.class.getName();
  open();
}
 
Example #15
Source File: SelenideTest.java    From healenium-web with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setUp() {
    Configuration.browser = MyGridProvider.class.getName();
}
 
Example #16
Source File: SelenideMultiTest.java    From healenium-web with Apache License 2.0 4 votes vote down vote up
@BeforeAll
public static void setUp() {
    Configuration.browser = MyGridProvider.class.getName();
}
 
Example #17
Source File: Selenide.java    From apicurio-studio with Apache License 2.0 4 votes vote down vote up
public static void init() {
    Configuration.reportsFolder = properties.get("selenide.reports.dir");
    Configuration.browser = "firefox";
    Configuration.headless = true;
}
 
Example #18
Source File: Neodymium.java    From neodymium-library with MIT License 3 votes vote down vote up
/**
 * Shortcut to turn on/off Selenide SoftAssertions <br>
 * You need to add the following JUnit rule to the test class to enable the feature
 * 
 * <pre>
 * &#64;Rule
 * public SoftAsserts softAsserts = new com.codeborne.selenide.junit.SoftAsserts();
 * </pre>
 * 
 * @param useSoftAssertions
 *            boolean if the Selenide soft assertion feature is activated
 */
public static void softAssertions(boolean useSoftAssertions)
{
    if (useSoftAssertions)
    {
        Configuration.assertionMode = AssertionMode.SOFT;
    }
    else
    {
        Configuration.assertionMode = AssertionMode.STRICT;
    }
}