getSource

Get source code of the page. This command won’t work in mobile environments for native apps. If you running hybrid tests make sure that you are in the webview before calling this command.

Usage

1
browser.getSource();

Example

getSource.js
1
2
3
4
5
6
it('should get the source of the html document', function () {
browser.url('http://webdriver.io');

var source = browser.getSource();
console.log(source); // outputs: "<!DOCTYPE html>\n<title>Webdriver.io</title>..."
});

Uses