回答

收藏

技术问答测试

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

  1. import org.openqa.selenium.By; ! P, R/ x+ n+ f' v' I
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement;
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5. import org.openqa.selenium.chrome.ChromeOptions;
  6. 7 ^7 |$ e4 k5 p# U0 `
  7. public class Main { 8 {, n% }" \" P1 |% X
  8.     public static void main(String[] args) { . q, E( e/ ~+ }$ \; n/ l( C+ X
  9.         ChromeOptions options=new ChromeOptions();
  10.         options.addArguments("--remote-allow-origins=*"); 9 J. \$ V* k! x, M& g
  11.         WebDriver webDriver=new ChromeDriver(options);
  12.         webDriver.get("https://www.baidu.com/");
  13.         //定位元素
  14.         //找到百度搜索框
  15.        WebElement element = webDriver.findElement(By.cssSelector(".s_ipt")); ) n3 }7 q4 ^  t6 Q, b
  16.        //输入软件测试 - W* g( F. q, A0 ]$ j8 D$ F
  17.         element.sendKeys("软件测试");
  18.     } ) P7 k7 p% t: T6 w  l
  19. }
复制代码
) u7 b+ D- ?; q1 c3 ]7 t
9 b- h+ Y7 s  V* B! u3 Y! g
我知道答案 回答被采纳将会获得5 金钱 已有0人回答
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则