码迷,mamicode.com
首页 > 其他好文 > 详细

selenium简单启动浏览器方式

时间:2019-04-07 09:51:17      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:repos   get   cti   简单   win   imp   ble   cli   one   

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:\pythonspacen\pyt\onea\drive\geckodriver.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简单启动浏览器方式

标签:repos   get   cti   简单   win   imp   ble   cli   one   

原文地址:https://blog.51cto.com/357712148/2374747

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!