0.0
No commit activity in last 3 years
No release in over 3 years
Simple DSL for Selenium
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

selenium-dsl

DSL for selenium

Using headless browser (Mac), you can change from "firefox" to "phantomjs"

> brew install phantomjs
> git clone https://github.com/detro/ghostdriver.git
> phantomjs ghostdriver/src/main.js
Ghost Driver running on port 8080

install:

gem installl selenium-dsl

create file:

go-wharsojo
firefox
visit http://google.com
:q=github wharsojo
:btnG~click
li.g[1]>a~click

headless(change "firefox" to "remote"):

remote http://localhost:8080

run it:

sd go-wharsojo -v

or chrome(change "firefox" to "chrome"):

$google     = visit http://google.com
$search     = :q=$0
$submit     = :btnG~click
$pick_first = li.g[1]>a~click

chrome
$google
$search github wharsojo
$submit
$pick_first

commandline

Selenium DSL 
============
> selenium-dsl <script-file>  [-mqrstv] #OR
> sd <script-file>  [-mqrstv] 
-----------------------------
m: mono    --> no color
q: quit    --> close browser
r: resize  --> resize browser
s: screenshot> error, screenshot!
t: trace   --> trace call stack
v: verbose --> parsing output 

Ex:
> sd go-test -m -q -v -r:800x600 -s:error_image   
> sd go-test -mqv -r:800x600 -s:error_image   
> sd go-test -mqvr:800x600 -s:error_image   
> sd go-test -mqvsr:800x600
> sd go-test -qr:800x600
> sd go-test -q
> sd go-test

Script-Reference:
-----------------
eng: <string> [params]    --> Commands
 ex: firefox
     visit http://google.com
     *browser: (firefox | chrome | remote | phantomjs)*
cmd: <css-cmd>            --> DOM Query (DQ)
 ex: li.g[1]>a
cmd: <css-cmd>[=<value>]  --> DQ and attr value=Id0123
 ex: :input_id=Id0123       # <input name="input_id"/>
cmd: <css-cmd>[~<action>] --> DQ and action (DQA)
 ex: li.g[1]>a~click
cmd: <css-cmd>[~<action>][=~<text>] --> DQA and check node text
 ex: li.g[1]>a~text=~Home
cmd: <css-cmd>[@<attr>][=~<text>] --> DQ and check node attr
 ex: :input_id@value=~ayam

Script-BASH-for-cron-job
------------------------
#!/bin/bash
txt=`sd my-website -mqs`
if [ $? -ne 0 ]
  then
    echo "Error!!!"
    echo -e "\r\n $txt"   > elog.txt
    cat emsg.txt elog.txt > email.txt
    ssmtp site.monitor@gmail.com < email.txt
  else echo "OK"
fi

https://github.com/wharsojo/selenium-dsl - Enjoy!!! 

reference:

http://code.google.com/p/selenium/downloads/list
http://code.google.com/p/selenium/wiki/RubyBindings
http://code.google.com/p/chromedriver/downloads/list
http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/SearchContext.html
http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/Element.html
http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/Server.html

MIT License!