Run sample Selenide test
Step 1: Setup environment
Requirements
- JDK (Highly recommended to use JDK 8 SE)
- Java build framework
- Selenide framework
- Access key
- You can generate an Access key using the following instruction – Access key
- Billing unit
- The billing unit is your team’s unique identifier, or just the word “personal” in the case of an individual account.
More information can be found here.
- The billing unit is your team’s unique identifier, or just the word “personal” in the case of an individual account.
Step 2: Run sample test
After setting up the environment, you can run your first Selenide test
package com.mobitru;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverConditions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.AbstractDriverOptions;
import static com.codeborne.selenide.Condition.visible;
import static java.lang.String.format;
import static java.time.Duration.ofMinutes;
import static org.openqa.selenium.By.className;
public class SeleniumDemoTest {
private static final String PROJECT_NAME = "epm-tstf";
private static final String API_KEY = "--------- YOU API KEY -----------";
private static final String SELENIUM_HUB = "browserhub-us.mobitru.com";
private final AbstractDriverOptions<? extends MutableCapabilities> options;
public SeleniumDemoTest() {
options = new ChromeOptions();
}
@BeforeEach
public void before() throws Exception {
Configuration.remote = format("https://%s:%s@%s/wd/hub", PROJECT_NAME, API_KEY, SELENIUM_HUB);
Configuration.pageLoadTimeout = ofMinutes(1).toMillis();
}
@Test
public void demoTest() {
Configuration.remote = format("https://%s:%s@%s/wd/hub", PROJECT_NAME, API_KEY, SELENIUM_HUB);
Configuration.pageLoadTimeout = ofMinutes(1).toMillis();
final String openUrl = "https://mobitru.com/";
Selenide.open(openUrl);
Selenide.$(className("get-access")).shouldBe(visible);
Selenide.webdriver().shouldHave(WebDriverConditions.url(openUrl));
Selenide.webdriver().shouldHave(WebDriverConditions
.title("Mobitru: Cloud and On-Prem Mobile App Testing"));
}
@AfterEach
public void after() {
Selenide.closeWebDriver();
}
}