- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
" f' e& s ^. h \
- import org.openqa.selenium.WebElement;
, A s0 G3 B. W6 P; U
- import org.openqa.selenium.chrome.ChromeDriver;
( D1 P$ x- Y' H6 u8 V
- import org.openqa.selenium.chrome.ChromeOptions;
-
- public class Main {
# d1 d( E& E$ \) d+ I
- public static void main(String[] args) {
! s" x- x" W5 e# j7 f; y1 v
- ChromeOptions options=new ChromeOptions();
- options.addArguments("--remote-allow-origins=*");
- WebDriver webDriver=new ChromeDriver(options);
- webDriver.get("https://www.baidu.com/");
b) q$ T" O, q# A& O
- //定位元素
6 L+ U8 N1 J- d! x; e+ Q
- //找到百度搜索框
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
; z* Y: f. c$ }0 x0 c
- //输入软件测试
* w3 s6 F& J% y: N/ @
- element.sendKeys("软件测试");
5 L8 K9 W3 @% Y" _* E4 p! P
-
' H0 z4 I0 Q7 m- g" ?' y
- }
- }
复制代码
1 c4 F' z: T2 }& |6 x
; y" a- Z# s+ m, N; ~8 w9 u
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|