Example usage for org.openqa.selenium WebDriver getPageSource

List of usage examples for org.openqa.selenium WebDriver getPageSource

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver getPageSource.

Prototype

String getPageSource();

Source Link

Document

Get the source of the last loaded page.

Usage

From source file:zz.pseas.ghost.login.taobao.LogInTaobaoWebDriver.java

License:Apache License

public static void main(String[] args) throws InterruptedException {
    WebDriver ie = BrowserFactory.getIE();
    ie.get("https://login.taobao.com/member/login.jhtml");

    Thread.sleep(5000);//  w  ww .j av a 2 s  .c om

    String tbuserNmae = "TBname";
    String tbpassWord = "TBpasssword";

    WebElement btn = ie.findElement(By.id("J_Quick2Static"));
    if (btn != null && btn.isDisplayed()) {
        btn.click();
    }

    ie.findElement(By.id("TPL_username_1")).clear();
    ie.findElement(By.id("TPL_username_1")).sendKeys(tbuserNmae);

    ie.findElement(By.id("TPL_password_1")).clear();
    ie.findElement(By.id("TPL_password_1")).sendKeys(tbpassWord);

    ie.findElement(By.id("J_SubmitStatic")).click();

    Thread.sleep(10000L);

    String html = ie.getPageSource();

    System.out.println(html);
    String url = ie.getCurrentUrl();
    System.out.println(url);
    /*WebElement phoneCheck = ie.findElement(By.id("J_GetCode"));
    if(phoneCheck!=null && phoneCheck.isDisplayed()){
       WebElement btn2 = ie.findElement(By.id("J_GetCode"));
       btn2.click();
    }*/

    //Thread.sleep(5000);

}