- WebDriver高级篇 - 获取测试对象属性
- 获取测试对象属性
- 1 getText
- 2 getAttribute title
- 3 getCssValue color font
- 4 getTag
- 5 getClass
关于获取测试对象属性还是直接上脚本吧…我真的太懒了…
WebDriver高级篇 - 获取测试对象属性 获取测试对象属性 1 getText 2 getAttribute title 3 getCssValue color font- Color:获取的为RGB编码
关于获取测试对象属性还是直接上脚本吧…我真的太懒了…
//基于Chrome浏览器
System.setProperty("webdriver.chrome.driver", "D:/Program Files/Java/jdk1.8.0_141/bin/chromedriver.exe");
WebDriver Demo15_Attribute_driver=new ChromeDriver();
Demo15_Attribute_driver.manage().window().maximize();
//浏览器最大化
Thread.sleep(3000);
Demo15_Attribute_driver.get
("file:///C:/Users/Administrator/Desktop/autoTest/bootstrap-snippet-login-form/attribute.html");
WebElement attribute = Demo15_Attribute_driver.findElement(By.xpath("//*[@id='tooltip']"));
System.out.println("Text:"+attribute.getText());
System.out.println("Title:"+attribute.getAttribute("title"));
System.out.println("Color:"+attribute.getCssValue("color"));
System.out.println("Font:"+attribute.getCssValue("font"));
System.out.println("Tag:"+attribute.getTagName());
System.out.println("Class:"+attribute.getClass());
Thread.sleep(3000);
Demo15_Attribute_driver.quit();



