Skip to content

Commit

Permalink
Changes in version 1.3.0
Browse files Browse the repository at this point in the history
------------------------
* selenium-java 3.141.59
* selenium docker 3.141.59-20210913
  • Loading branch information
hibissscus committed Sep 15, 2021
1 parent 6c534ef commit 55d1f94
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 111 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Changes in version 1.3.0
------------------------
* selenium-java 3.141.59
* selenium docker 3.141.59-20210913

Changes in version 1.0.3
------------------------
* Kotlin 1.5.30
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "testee"
version = "1.0.3"
version = "1.3.0"

repositories {
mavenCentral()
Expand All @@ -23,8 +23,8 @@ dependencies {
// kotlin
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.5.30")
// selenium
implementation("org.seleniumhq.selenium:selenium-support:4.0.0-rc-1")
implementation("org.seleniumhq.selenium:selenium-java:4.0.0-rc-1")
implementation("org.seleniumhq.selenium:selenium-support:3.141.59")
implementation("org.seleniumhq.selenium:selenium-java:3.141.59")
// testng
implementation("org.testng", "testng", "7.4.0")
// reportng
Expand Down
53 changes: 16 additions & 37 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,35 @@ services:
- selenium-hub
- chrome
- firefox
- edge
command: "gradle e2e -De2e.selenium=http://selenium-hub:4444"
command: "gradle e2e -De2e.selenium=http://selenium-hub:4444/wd/hub"
selenium-hub:
container_name: selenium-hub
image: selenium/hub:4.0.0-rc-2-prerelease-20210908
image: selenium/hub:3.141.59-20210913
ports:
- "4444:4444"
- "4443:4443"
- "4442:4442"
- 4444:4444
environment:
- TZ=Europe/Berlin
chrome:
container_name: chrome
image: selenium/node-chrome:4.0.0-rc-2-prerelease-20210908
shm_size: 2gb
image: selenium/node-chrome:3.141.59-20210913
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=1
- HUB_HOST=selenium-hub
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5
- TZ=Europe/Berlin
ports:
- "6901:5900"
firefox:
container_name: firefox
image: selenium/node-firefox:4.0.0-rc-2-prerelease-20210908
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=1
- TZ=Europe/Berlin
ports:
- "6911:5900"
edge:
container_name: edge
image: selenium/node-edge:4.0.0-rc-2-prerelease-20210908
shm_size: 2gb
image: selenium/node-firefox:3.141.59-20210913
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=1
- TZ=Europe/Berlin
ports:
- "6921:5900"
- HUB_HOST=selenium-hub
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5
- TZ=Europe/Berlin
4 changes: 1 addition & 3 deletions src/main/kotlin/testee/it/e2e/core/browser/Browser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package testee.it.e2e.core.browser
/**
* Enum for all possible [browser] which we can use.
*/
enum class Browser(val browser: String) {
enum class Browser(private val browser: String) {
FIREFOX("firefox"),
CHROME("chrome"),
EDGE("edge"),
SAFARI("safari")
}
65 changes: 7 additions & 58 deletions src/main/kotlin/testee/it/e2e/core/browser/WebDriverFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import com.google.common.base.Strings
import org.openqa.selenium.WebDriverException
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.edge.EdgeDriver
import org.openqa.selenium.edge.EdgeOptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.safari.SafariDriver
import org.openqa.selenium.safari.SafariOptions
import java.net.URL
import java.time.Duration
import java.util.concurrent.TimeUnit


/**
Expand All @@ -38,8 +34,6 @@ object WebDriverFactory {
return when (browser) {
Browser.FIREFOX -> initFirefoxWebDriver(headless, media, fake, selenium)
Browser.CHROME -> initChromeWebDriver(headless, mobile, media, fake, selenium)
Browser.EDGE -> initEdgeWebDriver(headless, media, fake, selenium)
Browser.SAFARI -> SafariDriver(SafariOptions())
}
}

Expand All @@ -49,9 +43,9 @@ object WebDriverFactory {
* @param url for browser [Browser]
*/
fun manageBrowser(driver: RemoteWebDriver, url: String, defaultWait: Long): RemoteWebDriver = driver.apply {
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(defaultWait))
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(defaultWait))
driver.manage().timeouts().scriptTimeout(Duration.ofSeconds(defaultWait))
driver.manage().timeouts().implicitlyWait(defaultWait, TimeUnit.SECONDS)
driver.manage().timeouts().pageLoadTimeout(defaultWait, TimeUnit.SECONDS)
driver.manage().timeouts().setScriptTimeout(defaultWait, TimeUnit.SECONDS)
driver.manage().deleteAllCookies()

// info about browser versions
Expand All @@ -76,19 +70,14 @@ object WebDriverFactory {
fun getInfo(driver: RemoteWebDriver) {
return when (driver) {
is ChromeDriver -> {
println("Chrome: " + driver.capabilities.browserVersion)
println("Chrome: " + driver.capabilities.version)
println("ChromeDriver: " + (driver.capabilities.getCapability("chrome") as Map<*, *>)["chromedriverVersion"])
}
is FirefoxDriver -> {
println("Firefox: " + driver.capabilities.browserVersion)
}
is EdgeDriver -> {
println("Edge: " + driver.capabilities.browserVersion)
}
is SafariDriver -> {
println("Safari: " + driver.capabilities.browserVersion)
println("Firefox: " + driver.capabilities.version)
}
else -> {
println("TODO")
}
}
}
Expand Down Expand Up @@ -196,44 +185,4 @@ object WebDriverFactory {
ChromeDriver(opt)
}
}


/**
* Initialize driver and starts browser for [Browser.EDGE]
* @param headless - use or not headless mode
* @param media - use or not media
* @param selenium - selenium hub address
*/
@Throws(Exception::class)
private fun initEdgeWebDriver(headless: Boolean, media: Boolean, fake: String, selenium: String): RemoteWebDriver {
val opt = EdgeOptions()

opt.setAcceptInsecureCerts(true)
opt.addArguments("--window-size=1300,900")
opt.addArguments("--lang=en")
opt.addArguments("--incognito")

if (headless) {
opt.setHeadless(headless)
opt.addArguments("--disable-dev-shm-usage")
}

if (fake.isNotEmpty()) {
opt.addArguments("--use-fake-ui-for-media-stream")
opt.addArguments("--use-fake-device-for-media-stream")
}

val prefs = HashMap<String, Any>()
prefs["download.default_directory"] = System.getProperty("user.dir")
// pass the argument 1 to allow and 2 to block
prefs["profile.default_content_setting_values.media_stream_mic"] = if (media) 1 else 2
prefs["profile.default_content_setting_values.media_stream_camera"] = if (media) 1 else 2
opt.setExperimentalOption("prefs", prefs)

return if (!Strings.isNullOrEmpty(selenium) && headless) {
RemoteWebDriver(URL(selenium), opt)
} else {
EdgeDriver(opt)
}
}
}
5 changes: 2 additions & 3 deletions src/main/kotlin/testee/it/e2e/core/pages/AbstractPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package testee.it.e2e.core.pages
import org.openqa.selenium.WebDriver
import org.openqa.selenium.support.PageFactory
import org.openqa.selenium.support.ui.WebDriverWait
import java.time.Duration

/**
* Main [AbstractPage] which implement [Page] interface.
Expand Down Expand Up @@ -33,10 +32,10 @@ abstract class AbstractPage(protected val driver: WebDriver) : Page {
}

override fun wait(): WebDriverWait {
return WebDriverWait(driver, Duration.ofSeconds(waitMax()))
return WebDriverWait(driver, waitMax())
}

override fun tick(): WebDriverWait {
return WebDriverWait(driver, Duration.ofSeconds(waitMin()))
return WebDriverWait(driver, waitMax())
}
}
10 changes: 5 additions & 5 deletions src/main/kotlin/testee/it/e2e/core/pages/Checks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOf
import org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated
import org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf
import org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated
import java.time.Duration
import java.util.concurrent.TimeUnit

interface Checks : Driver {
/**
* Set page load timeout in [milliseconds] for [driver]
*/
fun setPageLoadTimeout(milliseconds: Long) {
driver().manage().timeouts().pageLoadTimeout(Duration.ofMillis(milliseconds))
driver().manage().timeouts().implicitlyWait(Duration.ofMillis(milliseconds))
driver().manage().timeouts().scriptTimeout(Duration.ofMillis(milliseconds))
driver().manage().timeouts().pageLoadTimeout(milliseconds, TimeUnit.NANOSECONDS)
driver().manage().timeouts().implicitlyWait(milliseconds, TimeUnit.NANOSECONDS)
driver().manage().timeouts().setScriptTimeout(milliseconds, TimeUnit.NANOSECONDS)
}

/**
* Set implicit wait in [seconds] implicit wait for [driver]
*/
fun setImplicitWait(seconds: Long = waitMax()) {
driver().manage().timeouts().implicitlyWait(Duration.ofSeconds(seconds))
driver().manage().timeouts().implicitlyWait(seconds, TimeUnit.SECONDS)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class MatryoshkaTest : TestBase(url = "https://pixlr.com/x/", browser = Browser.
fun `01 create different emoji`() {
MatryoshkaPage(driver)
.open(url)
.closeAllModalDialogs()
.acceptCookieAgreement()
.openNewImageFromUrl(imageUrl)
.pixlrPreset()
.emoji()
Expand Down

0 comments on commit 55d1f94

Please sign in to comment.