1. 程式人生 > >利用Selenium模擬登陸百度demo

利用Selenium模擬登陸百度demo

public String parse(){
		driver.get(url);
		driver.findElement(By.cssSelector("div[id=u1] a[class=lb]")).click();
		driver.findElement(By.name("userName")).sendKeys("your username");
		driver.findElement(By.name("password")).sendKeys("your password");
		driver.findElement(By.cssSelector("input[id=TANGRAM__PSP_8__submit]")).click();
		String source = driver.getPageSource();
		System.out.println(source);
		return url;
		
	}