Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Web:selenium Automation practice

Shulou Source: shulou.com Published: 2022-06-02 23:57:08 09月27日 Update

web automation tool selection

Selenium is open source and free;

watir

loadrunner

QTP

Selenium development history

2004--

Tool set:

selenium IDE -fixfox plugin

selenium remote control (RC)--support js, complex tests

selenium Grid --distributed execution of tests, multiple machines, multiple systems

selenium WebDriver --native browser support, advanced tests for creating columns, scripting support in multiple languages

Selenium environment preparation

Workflow:

script--selenium --browser software

Steps:

Install Fixfox

Installing Java Environment

install eclipse

Selenium Development Project:

Creating Java Projects

lib library creation--new folder

Download selenium server jar package locally

paste this jar package under libs

java build path--add jar package

The diagram illustrates the whole project environment configuration process

1. Open Eclipse

2. Create a new project

3. Create a net folder named libs

4. Download selenium jar package locally, download address:

http://docs.seleniumhq.org/download/

Selenium-server-standalone-2.52.0.jar is required.

You can also add source packages

selenium-java-2.53.1.jar、selenium-java-2.53.1-srcs.jar ;

5. Drag the package downloaded in step 4 directly to the libs folder

6. Follow these steps to add jar package to

7. Click OK, you can;

8. Create a class and write a script.

The base script template is:

public class test {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();

driver.get("http://photo.163.com ");

WebElement name = driver.findElement(By.name("username"));

WebElement password = driver.findElement(By.name("password"));

WebElement login = driver.findElement(By.id("photo_index_login"));

//randomly click a dot on the screen to remove a hint div

WebElement loginview = driver.findElement(By.id("photo_index_login_hint"));

name.sendKeys("ynotetest30@163.com");

//click the screen randomly to remove a hint div

loginview.click();

password.sendKeys("****);

login.click();

//Close browser

driver.quit();

}

}

example

search Selenium

Element positioning: xpath

Additional:

Tags: Scripts projects browsers environments support testing browsing screens tools automation complexity advanced examples elements distributed development history addresses foundations multiple multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia vpn OPPO Reno Redmi