- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
* K2 o% h. ]3 r# ?+ r& w+ ]
- import org.openqa.selenium.WebElement;
$ K1 J5 ?! u& X
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
( g# v; E) K, E4 [1 X# h
-
- public class Main {
- public static void main(String[] args) {
- ChromeOptions options=new ChromeOptions();
- options.addArguments("--remote-allow-origins=*");
+ J' |8 a( i# e$ |* c+ {, X
- WebDriver webDriver=new ChromeDriver(options);
- webDriver.get("https://www.baidu.com/");
7 l6 |, t' U' a3 ^* O" D
- //定位元素
" {( S; Q+ t a- u4 C& Z5 j
- //找到百度搜索框
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
- //输入软件测试
3 q5 s; D! ^% R' _3 s
- element.sendKeys("软件测试");
' |8 |. J! ~; p# n* d
-
- }
- }
复制代码
/ c" O/ d& @6 G! H, R3 K0 t& \4 u3 ~4 i0 W2 _
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|