java+selenium3学习之一启动firefox浏览器
package ceshi.com.lessons; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class LuanchFirefox { public static void main(String[] args) { System.setProperty ( "webdriver.firefox.bin" , "D:/Program Files (x86)/Mozilla Firefox/firefox.exe" ); System.setProperty("webdriver.gecko.driver", ".\\Tools\\geckodriver.exe"); WebDriver dr=new FirefoxDriver(); dr.manage().window().maximize(); dr.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); dr.get("https://www.baidu.com"); dr.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); dr.findElement(By.id("kw")).sendKeys("selenium 3"); dr.findElement(By.id("su")).click(); System.out.println("当前打开页面的标题是:" + dr.getTitle()); dr.quit(); } }
javascript
posted on 2017-08-08 14:15 sunny_2016 阅读(230) 评论(0) 编辑 收藏 举报