- import org.openqa.selenium.By;
% n! R! N% D& m
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
' V; k* ?5 ]% W
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
4 Z1 M& |) {# |* o& k
-
- public class Main {
- public static void main(String[] args) {
5 ?4 i* z! K4 Y" M) H+ K5 Q
- ChromeOptions options=new ChromeOptions();
- options.addArguments("--remote-allow-origins=*");
- WebDriver webDriver=new ChromeDriver(options);
2 P- ^" c" H6 D {- z( a
- webDriver.get("https://www.baidu.com/");
0 z# g" Y4 B9 @9 p( E
- //定位元素
- //找到百度搜索框
% t) b% y4 H% v3 I2 s5 _' }
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
- //输入软件测试
- element.sendKeys("软件测试");
# F z' G+ c3 a0 d) M8 n# Y$ i
-
+ ~; Y5 y! ]; `7 Z* c
- }
- }
复制代码
0 r- A0 E4 r6 @4 J+ I H' A
/ w3 X% t. s7 F- z0 ]* R
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|