回答

收藏

技术问答测试

技术问答 技术问答 184 人阅读 | 0 人回复 | 2023-08-08

  1. import org.openqa.selenium.By; % n! R! N% D& m
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement; ' V; k* ?5 ]% W
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5. import org.openqa.selenium.chrome.ChromeOptions; 4 Z1 M& |) {# |* o& k
  6. public class Main {
  7.     public static void main(String[] args) { 5 ?4 i* z! K4 Y" M) H+ K5 Q
  8.         ChromeOptions options=new ChromeOptions();
  9.         options.addArguments("--remote-allow-origins=*");
  10.         WebDriver webDriver=new ChromeDriver(options); 2 P- ^" c" H6 D  {- z( a
  11.         webDriver.get("https://www.baidu.com/"); 0 z# g" Y4 B9 @9 p( E
  12.         //定位元素
  13.         //找到百度搜索框 % t) b% y4 H% v3 I2 s5 _' }
  14.        WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
  15.        //输入软件测试
  16.         element.sendKeys("软件测试"); # F  z' G+ c3 a0 d) M8 n# Y$ i
  17. + ~; Y5 y! ]; `7 Z* c
  18.     }
  19. }
复制代码

0 r- A0 E4 r6 @4 J+ I  H' A
/ w3 X% t. s7 F- z0 ]* R
我知道答案 回答被采纳将会获得5 金钱 已有0人回答
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则