WebDriver實(shí)現(xiàn)自動(dòng)化打開(kāi)IE中的google網(wǎng)頁(yè)并實(shí)現(xiàn)搜索
WebDriver實(shí)現(xiàn)自動(dòng)化打開(kāi)IE中的google網(wǎng)頁(yè)并實(shí)現(xiàn)搜索,需要導(dǎo)入WebDriver相關(guān)的jar包,設(shè)置好環(huán)境變量。
package com.feng.domain;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class TestWebDriver {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.ie.driver", "C:\\testwebdriver\\IEDriverServer.exe");
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(ieCapabilities);
driver.get("http://www.google.com.hk/");
try {
Thread.sleep(6000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// System.out.println("The current url is:" + driver.getCurrentUrl());
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("days");
WebElement elementBtn = driver.findElement(By.xpath("http://input[@name='btnG']"));
elementBtn.click();
try {
Thread.sleep(6000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.close();
}
}
相關(guān)文章
使用@TableField(updateStrategy=FieldStrategy.IGNORED)遇到的坑記錄
這篇文章主要介紹了使用@TableField(updateStrategy=FieldStrategy.IGNORED)遇到的坑及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
解析spring boot與ireport 整合問(wèn)題
本文通過(guò)實(shí)例代碼給大家介紹了spring boot 與 ireport 整合問(wèn)題,關(guān)于pom文件依賴的問(wèn)題通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-10-10
Mybatis入門(mén)教程(四)之mybatis動(dòng)態(tài)sql
這篇文章主要介紹了Mybatis入門(mén)教程(四)之mybatis動(dòng)態(tài)sql的相關(guān)資料,涉及到動(dòng)態(tài)sql及動(dòng)態(tài)sql的作用知識(shí),本文介紹的非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09
Java concurrency之公平鎖(二)_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要為大家詳細(xì)介紹了Java concurrency之公平鎖的第二篇內(nèi)容,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
redis redisson 限流器的實(shí)例(RRateLimiter)
這篇文章主要介紹了redis redisson 限流器的實(shí)例(RRateLimiter),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07
SpringBoot如何實(shí)現(xiàn)分離資源文件并打包
這篇文章主要介紹了SpringBoot如何實(shí)現(xiàn)分離資源文件并打包,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06
新的Java訪問(wèn)mysql數(shù)據(jù)庫(kù)工具類的操作代碼
本文通過(guò)實(shí)例代碼給大家介紹新的Java訪問(wèn)mysql數(shù)據(jù)庫(kù)工具類的方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2021-12-12
SpringBoot基于JAXB實(shí)現(xiàn)天地圖路徑規(guī)劃結(jié)果XML轉(zhuǎn)JSON
這篇文章主要為大家詳細(xì)介紹了SpringBoot如何基于JAXB實(shí)現(xiàn)將天地圖路徑規(guī)劃結(jié)果XML轉(zhuǎn)JSON功能,文中的示例代碼講解詳細(xì),需要的可以了解下2025-02-02

