-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow WebDriver to use different Selenium drivers (#2225)
- Loading branch information
1 parent
5c57e6e
commit 4c71c7b
Showing
4 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
maestro-web/src/main/kotlin/maestro/web/selenium/ChromeSeleniumFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package maestro.web.selenium | ||
|
||
import org.openqa.selenium.WebDriver | ||
import org.openqa.selenium.chrome.ChromeDriver | ||
import org.openqa.selenium.chrome.ChromeDriverService | ||
import org.openqa.selenium.chrome.ChromeOptions | ||
import org.openqa.selenium.chromium.ChromiumDriverLogLevel | ||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
class ChromeSeleniumFactory : SeleniumFactory { | ||
|
||
override fun create( | ||
isStudio: Boolean | ||
): WebDriver { | ||
System.setProperty("webdriver.chrome.silentOutput", "true") | ||
System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true") | ||
Logger.getLogger("org.openqa.selenium").level = Level.OFF | ||
Logger.getLogger("org.openqa.selenium.devtools.CdpVersionFinder").level = Level.OFF | ||
|
||
val driverService = ChromeDriverService.Builder() | ||
.withLogLevel(ChromiumDriverLogLevel.OFF) | ||
.build() | ||
|
||
return ChromeDriver( | ||
driverService, | ||
ChromeOptions().apply { | ||
addArguments("--remote-allow-origins=*") | ||
addArguments("--disable-search-engine-choice-screen") | ||
addArguments("--lang=en") | ||
if (isStudio) { | ||
addArguments("--headless=new") | ||
addArguments("--window-size=1024,768") | ||
setExperimentalOption("detach", true) | ||
} | ||
} | ||
) | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
maestro-web/src/main/kotlin/maestro/web/selenium/SeleniumFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package maestro.web.selenium | ||
|
||
import org.openqa.selenium.WebDriver | ||
|
||
interface SeleniumFactory { | ||
|
||
fun create( | ||
isStudio: Boolean = false | ||
): WebDriver | ||
|
||
} |