Last active
April 27, 2016 06:37
-
-
Save cedeber/be01f5dfae38bdf3b16f01b66f08c6d5 to your computer and use it in GitHub Desktop.
Selenium Async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require( "should" ), | |
webdriver = require( "selenium-webdriver" ), | |
test = require( "selenium-webdriver/testing" ); | |
test.describe( "MouseEvent", function () { | |
var driver, windo; | |
this.timeout( 5000 ); | |
test.before( function () { | |
driver = new webdriver.Builder() | |
.withCapabilities( webdriver.Capabilities.phantomjs() ) | |
.forBrowser( "phantomjs" ) | |
.build(); | |
windo = driver.manage().window(); | |
windo.setSize( 320, 568 ); | |
driver.get( `${ __dirname }/browser/mouseevent.html` ); | |
} ); | |
test.after( function () { | |
driver.quit(); | |
} ); | |
test.describe( "#pageXY", function () { | |
test.it( "should be x:50px and y:230px", function ( done ) { | |
driver.findElement( webdriver.By.id( "box" ) ).then( function ( element ) { | |
driver.executeAsyncScript( function () { | |
var cb = arguments[ arguments.length - 1 ]; | |
var box = document.getElementById( "box" ); | |
box.addEventListener( "click", function( event ) { | |
cb( event ); | |
} ); | |
} ).then( function ( event ) { | |
event.pageX.should.be.exactly( 50 ).and.be.a.Number(); | |
event.pageY.should.be.exactly( 230 ).and.be.a.Number(); | |
done(); | |
} ); | |
var seq = new webdriver.ActionSequence( driver ); | |
seq.mouseMove( element ).click(); | |
setTimeout( function() { seq.perform(); }, 0 ); | |
} ); | |
} ); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment