s4553711
5/5/2017 - 1:24 PM

A test for using Geb

A test for 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") }
    }
}

def d = new PhantomJSDriver()
d.manage().window().size = new Dimension(1980, 1024)

Browser.drive {
	config.reportsDir = new File('/home/my/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 = "userName"
        password = "passWord"
    }

    loginButton.click()

	$("a", id: "2415_anchor").click()
	//Thread.sleep(3000)
	waitFor {
		$('.loading-mask').displayed == false
	}
	assert $('.loading-mask').displayed == false
	assert $('span#panel-title').text() == "CK"

	$('#add-analysis').click()
	waitFor {
		$('.analysis-selector').displayed == true
	}
	assert $('div.analysis-inner').children('div').getAt(1).text() == 'Variant Detection'

	//assert $('.jstree-anchor').text() == '123'
	$('.jstree-anchor').collect{ println "get: "+it.text() }

	report 'codedata-home'
}.quit()