selenium简单启动浏览器方式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了selenium简单启动浏览器方式相关的知识,希望对你有一定的参考价值。
java
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0-beta1</version>
<scope>compile</scope>
</dependency>
ChromeDriver driver = new ChromeDriver();
driver.navigate().to("http://www.baidu.com");
Thread.sleep(6000);
driver.close();
driver.findElement(By.id("kw")).sendKeys("百度");
python
from selenium import webdriver
driver = webdriver.Firefox(executable_path=‘D:pythonspacenpytoneadrivegeckodriver.exe‘)
driver.maximize_window()
driver.get("http://www.baidu.com")
driver.find_element_by_id("kw").send_keys("美丽")
driver.find_element_by_xpath(‘//*[@id="su"]‘).click()
以上是关于selenium简单启动浏览器方式的主要内容,如果未能解决你的问题,请参考以下文章