.getLocationInView()
Determine an element's location on the screen once it has been scrolled into view. Uses elementIdLocationInView
protocol command.
Parameters:
Name | Type | description |
---|---|---|
selector |
string | The CSS/Xpath selector used to locate the element. |
callback |
function | Callback function which is called with the result value. |
Returns
Type | description |
---|---|
x: number, y: number | The X and Y coordinates for the element on the page. |
this.demoTest = function (browser) { browser.getLocationInView("#main ul li a.first", function(result) { this.assert.equal(typeof result, "object"); this.assert.equal(result.status, 0); this.assert.equal(result.value.x, 200); this.assert.equal(result.value.y, 200); }); };
1down voteaccepted
|
If you are using JQuery you can do it like this:
Or using plain JavaScript:
|
将屏幕滚动到底部实例:
module.exports = { 'your-test': function (browser) { browser .url("https://www.sohu.com/") .pause(1000) .waitForElementPresent('body', 2000, "Be sure that the page is loaded") .maximizeWindow() .pause(1000) .execute(function() { window.scrollBy(0, 10000000); }, []) .pause(2000) .end(); } }