Table of Contents
Selenimum is inspired by dom96/webdriver.
save docker-compose.yaml to your woriking directory.
and up by docker-compose.
version: '3'
services:
selenium-hub:
image: selenium/hub:3.141.59-20210830
container_name: selenium-hub
ports:
- 4444:4444
environment:
- GRID_MAX_SESSION=10
firefox: &node
image: selenium/node-firefox:3.141.59-20210830
container_name: selenium-firefox
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
- NODE_MAX_SESSION=5
chrome:
<<: *node
image: selenium/node-chrome:3.141.59-20210830
container_name: selenium-chrome
docker-compose up -d --remove-orphans
import selenimum, strformat
proc main() =
let
driver = newSeleniumWebDriver()
session = driver.newSession()
defer:
session.deleteSession()
try:
# navigate to Yahoo!JAPAN
session.navigateTo("https://www.yahoo.co.jp/")
let title = session.getTitle()
echo(&"page title:{title}")
session.saveScreenshot("yahoo-japan.png")
echo("screenshot saved.")
except Exception as e:
echo("ERROR!!", e.getStackTrace())
main()
if you want to use firefox.
import selenimum, json
let
capabilities = %*{
"desiredCapabilities": {
"browserName": "firefox"
},
"requiredCapabilities": {}
}
session = driver.newSession(capabilities=capabilities)
import selenimum, strformat
proc main() =
selenium "http://selenium-hub:4444/wd/hub":
chrome:
# navigate to Yahoo!JAPAN
navigateTo "https://www.yahoo.co.jp/"
let title = session.getTitle()
echo(&"page title:{title}")
session.saveScreenshot("yahoo-japan.png")
echo("screenshot saved.")
try:
main()
except Exception as e:
echo("ERROR!!", e.getStackTrace())
if you want to use firefox.
import selenimum, strformat
proc main() =
selenium "http://selenium-hub:4444/wd/hub":
firefox:
# navigate to Yahoo!JAPAN
navigateTo "https://www.yahoo.co.jp/"
let title = session.getTitle()
echo(&"page title:{title}")
session.saveScreenshot("yahoo-japan.png")
echo("screenshot saved.")
try:
main()
except Exception as e:
echo("ERROR!!", e.getStackTrace())
-
Latest release version
https://myamyu.github.io/selenimum/ -
Development version
https://myamyu.github.io/selenimum/develop/