Self_Java + Selenium + Maven 環境搭建步驟

來源:互聯網
上載者:User

標籤:origin   變數   搭建   build   test   har   劃線   字母   utf-8   

轉自:http://www.jianshu.com/p/3c05e8c9ee81

我們使用Java+Selenium WebDriver 來進行環境的搭建,同樣分為兩個部分:

  1. 安裝Java 和 intellij IDEA
  2. 引入指定Selenium的 Maven使用的pom.xml檔案

Maven 是一個用於項目構建的工具,通過它便捷的管理項目的生命週期。同時 Maven 不只是一個簡單的項目構建工具,還是一個依賴管理工具和項目資訊管理工具。它提供了中央倉庫,能幫我們自動下載構建。

標準的安裝步驟

  1. 選擇Java的版本並安裝 Java 1.8

  2. 使用IDEA建立Project

    • New Project | Maven Project

        
      • GroupId:org.seleniumhq.selenium
      • ArtifactId:selenium-parent
      • Version:2.53.1
    • 複製 下列xml檔案selenium-pom.xml的內容到pom.xml中

      <?xml version="1.0" encoding="UTF-8"?><project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-parent</artifactId> <version>2.53.1</version> </parent> <artifactId>selenium-server</artifactId> <name>selenium-server</name> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-remote-driver</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-exec</artifactId> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> </build></project>

      ?

開始使用WebDriver

在使用WebDriver之前,我們需要先做一些語言的背景學習。主要包括物件導向的理念、Python的基本使用以及Java的基本使用幾個部分。

  • 物件導向的理念

    類,Class,指的是一個模板,一種設計範本。

    • 對象:對象是類的一個執行個體,有狀態和行為。例如,一隻熊貓是一個對象,它的狀態有:名字、年齡、性別;行為有:賣萌、吃竹子等。

      • 狀態:成員變數
      • 行為:方法
    • 類:類是一個模板,一張圖紙,它描述一類對象的行為和狀態,把這個模板或圖紙實現以後,就是一個對象。

  • Python的使用

    PyCharm工具是Python的編程工具,.py檔案是Python的副檔名。

    Python的檔案使用 xxx_xxx.py的方式命名,單詞全部小寫,中間用底線加入。

    關於Python的學習,可以參考以下兩個課程:

    • Python入門,http://www.imooc.com/learn/177
    • Python進階,http://www.imooc.com/learn/317
  • Java的使用

    intellij IDEA工具是Java的編程工具。

    Java的檔案使用XxxYyy.java的大駱駝方式命名,單詞的第一個字母大寫。

    關於Java的學習,可以參考以下兩個課程:

    • Java入門第一季,http://www.imooc.com/learn/85
    • Java入門第二季,http://www.imooc.com/learn/124

 

Self_Java + Selenium + Maven 環境搭建步驟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.