mport org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class BaiduDemo {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","D:\\driver\\chromedriver.exe"); //指定驱动路径
WebDriver driver =new ChromeDriver();
driver.get("http://www.baidu.com");
//定位并点击登录.
driver.findElement ( By.xpath ( "//*[@id='u1']/a[7]" ) ).click ();
Thread.sleep ( 1000 );
//出现的扫码页面登录 定位并点击选择用户登录
driver.findElement ( By.xpath ( ".//*[@id='TANGRAM__PSP_10__footerULoginBtn']" ) ).click ();
//定位用户名文本框
WebElement userName = driver.findElement(By.id("TANGRAM__PSP_10__userName"));
userName.sendKeys("test username");
//定位密码文本框
WebElement password =
selenium 3 java 元素高亮显示
最新推荐文章于 2022-10-02 00:04:43 发布