mirror of
https://github.com/myamyu/selenimum
synced 2026-01-14 20:11:40 +00:00
No description
| .devcontainer | ||
| .github/workflows | ||
| examples | ||
| src | ||
| tests | ||
| .gitignore | ||
| docker-compose.yaml | ||
| LICENSE | ||
| README.adoc | ||
| selenimum.nimble | ||
| selenium-by-curl.adoc | ||
| vscode.docker-compose.yaml | ||
| vscode.dockerfile | ||
:toc: left
:sectnums:
= Selenimum
Selenimum is inspired by https://github.com/dom96/webdriver[dom96/webdriver].
== About
WebDriver for Selenium(selenium-hub) by Nim.
== Usage
=== launch selenium hub
save docker-compose.yaml to your woriking directory. +
and up by docker-compose.
[source,yaml]
----
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
----
[source,sh]
----
docker-compose up -d --remove-orphans
----
=== control selenium example
[source,nim]
----
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.
[source,nim]
----
import selenimum, json
let
capabilities = %*{
"desiredCapabilities": {
"browserName": "firefox"
},
"requiredCapabilities": {}
}
session = driver.newSession(capabilities=capabilities)
----
=== control selenium example by macro
[source,nim]
----
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.
[source,nim]
----
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())
----
== Docs
* Latest release version +
https://myamyu.github.io/selenimum/
* Development version +
https://myamyu.github.io/selenimum/develop/