/*
 * (C) Copyright 2019 Boni Garcia (http://bonigarcia.github.io/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package io.github.bonigarcia.seljup.test.advance;

// tag::snippet-in-doc[]
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Disabled;
// tag::snippet-in-doc[]
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.github.bonigarcia.seljup.DriverCapabilities;
import io.github.bonigarcia.seljup.DriverUrl;
import io.github.bonigarcia.seljup.SeleniumJupiter;

@Disabled("Sauce Labs credentials required")
// tag::snippet-in-doc[]
@ExtendWith(SeleniumJupiter.class)
class SauceLabsJupiterTest {

    @DriverUrl
    String url = "https://ondemand.eu-central-1.saucelabs.com/wd/hub";

    @DriverCapabilities
    DesiredCapabilities capabilities = new DesiredCapabilities();
    {
        capabilities.setCapability("username", "<my-saucelabs-user>");
        capabilities.setCapability("accessKey", "<my-saucelabs-key>");
        capabilities.setCapability("browserName", "Chrome");
        capabilities.setCapability("platform", "Windows 10");
        capabilities.setCapability("version", "59.0");
        capabilities.setCapability("name", "selenium-jupiter-and-saucelabs");
    }

    @Test
    void testWithSaucelabs(RemoteWebDriver driver) {
        driver.get("https://bonigarcia.github.io/selenium-jupiter/");
        assertThat(driver.getTitle())
                .contains("JUnit 5 extension for Selenium");
    }

}
// end::snippet-in-doc[]

@@ -792,76 +792,142 @@
 api.
-Disabled;%0A// tag::snippet-in-doc%5B%5D%0Aimport org.junit.jupiter.api.Test
+Test;%0Aimport org.junit.jupiter.api.condition.EnabledIfSystemProperties;%0Aimport org.junit.jupiter.api.condition.EnabledIfSystemProperty
 ;%0Aim
@@ -1241,76 +1241,195 @@
 ;%0A%0A@
-Disabled(%22S
+EnabledIfSystemProperties(%7B%0A        @EnabledIfSystemProperty(named = %22s
 auce
- 
 Labs
- credentials required%22)%0A// tag::snippet-in-doc%5B%5D
+Username%22, matches = %22.*%22),%0A        @EnabledIfSystemProperty(named = %22sauceLabsPassword%22, matches = %22.*%22) %7D)
 %0A@Ex
@@ -1723,30 +1723,64 @@
 me%22,
- %22%3Cmy-
+%0A                System.getProperty(%22
 sauce
-labs-user%3E%22
+LabsUsername%22)
 );%0A 
@@ -1829,29 +1829,64 @@
 ey%22,
- %22%3Cmy-
+%0A                System.getProperty(%22
 sauce
-labs-key%3E%22
+LabsPassword%22)
 );%0A 

Disable test conditionally based on the existence of system properties