Skip to content

Instantly share code, notes, and snippets.

@haisi
Created February 16, 2017 13:26
Show Gist options
  • Select an option

  • Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.

Select an option

Save haisi/514eeec884b6c45fcd8b25a79a7af2db to your computer and use it in GitHub Desktop.

Revisions

  1. haisi created this gist Feb 16, 2017.
    21 changes: 21 additions & 0 deletions selenium-tester.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var webdriver = require('selenium-webdriver');
    var keyword = "Magic";

    var driver = new webdriver.Builder().
    usingServer('http://localhost:4444/wd/hub/').
    withCapabilities(webdriver.Capabilities.chrome()).
    build();
    driver.get('http://www.google.com');
    driver.findElement(webdriver.By.name('q')).sendKeys(keyword);
    driver.findElement(webdriver.By.name('btnG')).click();
    driver.wait(function() {

    return driver.getTitle().then(function(title) {
    return driver.getPageSource().then(function(html) {
    console.log(html);
    return true;
    });
    });
    }, 1000);

    driver.quit();