A inline script for web automation test using Geb
@Grab("org.gebish:geb-core:1.1.1")
//@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.53.0")
//@Grab("org.seleniumhq.selenium:selenium-support:2.53.0")
//@Grab("org.seleniumhq.selenium:selenium-htmlunit-driver:2.52.0")
@Grab("com.github.detro.ghostdriver:phantomjsdriver:1.1.0")
//@Grab("com.codeborne:phantomjsdriver:1.3.0")
import geb.Browser
import geb.Page
import org.openqa.selenium.phantomjs.PhantomJSDriver
import org.openqa.selenium.Dimension
def keywords = args.join(' ')
class LoginPage extends Page {
static url = "http://hipipe.ncgm.sinica.edu.tw/workspace/login.jsp"
static at = { heading.text() == "HiPipe Professional Beta" }
static content = {
heading { $("div.logo") }
loginForm { $("form[name='loginform']") }
loginButton(to: DashboardPage) { $("input[name=submit]") }
}
}
class DashboardPage extends Page {
def setup() {
browser.driver.javascriptEnabled = true
driver.javascriptEnabled = true
}
static url = "http://hipipe.ncgm.sinica.edu.tw/workspace/#node/2415"
static at = {
heading2.text() == "Logout"
}
static content = {
heading2 { $("a.logout-btn") }
}
}
class ProjectPage extends Page {
static url = "http://hipipe.ncgm.sinica.edu.tw/workspace/#node/2415"
static at = {
waitFor {
$('.loading-mask').displayed == false
}
heading.text() == "Logout"
projectName.text() == "CK"
}
static content = {
heading { $("a.logout-btn") }
projectName { $('span#panel-title') }
addAnalysisBtn { $('#add-analysis') }
}
def seeProject(String pid) {
//$("a", id: pid+"_anchor").click()
//waitFor {
// $('.loading-mask').displayed == false
//}
}
}
class DenovoPage extends Page {
static url = "http://hipipe.ncgm.sinica.edu.tw/workspace/#node/2186"
static at = {
waitFor {
$('.loading-mask').displayed == false
}
kmerVal.text() == "53"
}
static content = {
kmerVal { $('div.term') }
}
def editDemo(String target) {
assert $('#container').displayed == false
$('#'+target).click()
assert $('#container').displayed == true
assert $('#container p').text() == "You don't have permission to perform this task"
}
}
def d = new PhantomJSDriver()
d.manage().window().size = new Dimension(1980, 1024)
def cf = new Browser().getConfig().rawConfig
Browser.drive {
config.reportsDir = new File('/home/s4553711/tmp/Geb')
//go 'http://hipipe.ncgm.sinica.edu.tw/workspace/login.jsp'
//$('form#tsf').with {
// q = keywords
// btnK().click()
//}
//assert $("div.logo").text() == "HiPipe Professional Beta"
//driver.javascriptEnabled = true
setDriver(d)
to LoginPage
assert at(LoginPage)
loginForm.with {
username = config.rawConfig.hipipe.user
password = config.rawConfig.hipipe.password
}
loginButton.click()
//$("a", id: "2415_anchor").click()
//waitFor {
// $('.loading-mask').displayed == false
//}
//assert $('.loading-mask').displayed == false
//assert $('span#panel-title').text() == "CK"
//assert $('.jstree-anchor').text() == '123'
//$('.jstree-anchor').collect{ println "get: "+it.text() }
// Test for the project page
to ProjectPage
addAnalysisBtn.click()
waitFor {
$('.analysis-selector').displayed == true
}
assert $('div.analysis-inner').children('div').getAt(0).text() == "Haplotype-based\nVariant Detection"
assert $('div.analysis-inner').children('div').getAt(1).text() == 'Variant Detection'
assert $('div.analysis-inner').children('div').getAt(2).text() == "De Novo\nAssembly"
assert $('div.analysis-inner').children('div').getAt(3).text() == "Exome CNV\nDetection"
// Test for the add sample page
$('#flash-title').click()
waitFor {
$('.loading-mask').displayed == false
}
//assert $('#edit-sample-name').displayed == true
assert $('#edit-sample-name').value() == ""
assert $('.button', id: 'save').text() == "Save"
report 'codedata-home'
to DenovoPage
editDemo "editAnalysis"
}.quit()
hipipe {
user = "user"
password = "password"
}