Selenium webdriver Software Test Experiment 2

Source: Internet
Author: User
Tags xpath

This is my experiment 2 of the report, has been finished the process of writing to Word, so directly affixed to word, but the picture can not come over, and do not want a Zhang inserted, so voted the manuscript of Baidu Library, but has not passed it, and so on, I put the address of Baidu Library, go to this link, Can be illustrated with illustrations.

LAB2 Selenium IDE

1. Firebug. 1

(1) installation ... 1

(2) Basic use ... 1

2. Firepath. 2

(1) installation ... 2

(2) Use ... 2

3. Selenium IDE. 3

(1) installation ... 3

(2) Selenium's Common toolbar ... 3

(3) Firefox new installed plugin in the toolbar does not show the solution ... 4

4. Webdriver configuration ... 4

5. Javacsv.jar Package (read CSV file required) ... 5

6. Firefox version and some configuration issues ... 5

(1) How to view Firefox version ... 5

(2) No Firefox updates ... 6

7. Homework ... 7

(1) Job requirements ... 7

(2) Finish the homework ... 7

8. Git basic use ... 13

9. GitHub Code Address ... 13

1. Firebug (1) installation

Install the add-ons in Firefox and press F12 to start the Firebug plugin.

(2) Basic use

A) hover the mouse over the code area of the HTML panel (hovering over the label name) to see the corresponding page element of the page highlighted. In this way, you can know the corresponding elements and locations that the HTML code displays on the page.

b) Firebug's "View" function.

After clicking the button, hover the mouse pointer over an element on the page to highlight the code that corresponds to the element in Firebug.

So (2) (3) Two functions are corresponding, click on the code in the HTML panel, automatically find the corresponding page elements; hover the mouse over the page element after clicking the "View" function and automatically display the corresponding code in the HTML panel.

c) The role of other tab bars.

CSS: The CSS style sheet code that displays the page;

Script: Displays the JavaScript code of the page;

Dom: Displays the DOM properties of the page;

Network: Displays the time that occurs when a page generates a network request;

Cookies: Displays the cookie information generated by the page.

2. Firepath (1) installation

Install in Firefox's add-ons.

(2) Use

A) Use the Firepath plugin to get the XPath expression for the page element.

XPath, which is an XML Path Language (Xmlpathlanguage), is a language used to determine the location of a part of an XML document.

Right-click on the page element, select "Inspect in Firepath", highlight the code in the Firepath panel, right-click the "Copy Xpath selector" in the tab header, and paste the XPath expression into something like Notepad.

or right-click on the page element and select "Inspect in Firepath", where you can copy the XPath expression in the Firepath panel.

Drop-down menu, you can choose to get a positioning expression such as CSS.

3. Selenium IDE (1) installation

Enter the following URL, search for installation, and note install the Selenium IDE instead of the Selenium IDE button:

Https://addons.mozilla.org/en-US/firefox/search/?q=selenium+IDE&appver=52.0&platform=windows

(2) Common toolbar of Selenium

Button "Control bar for test case execution Speed":

: Pause or Resume

: Step into the button.

Buttons: The app Rollup feature, which is an advanced feature that combines multiple command lines into one command execution.

(3) Firefox new installed plugin in the toolbar does not display the workaround

Http://jingyan.baidu.com/article/4665065821f144f549e5f83a.html

4. Configuration of the Webdriver

The following is the webdriver of the earlier version of the address, the new version of the online example less, afraid of a variety of problems, directly abandoned:

http://selenium-release.storage.googleapis.com/index.html?path=2.52/

The following URL describes how to configure Webdriver in Eclipse, which is actually importing the jar package: http://www.cnblogs.com/Crystalling/p/6050884.html

5. Javacsv.jar package (required to read CSV file)

Write this job needs to read the CSV file, so also to download another Javacsv.jar package, as the above import Webdriverjar package to import the following jar package can be:

Http://xiazai.jb51.net/201608/yuanma/javcsv (jb51.net). rar

6. Firefox version and some configuration issues

Selenium in the high version of the Firefox browser issue a lot, so it is recommended to use its low version, I use 43.0.1 version no problem.

(1) How to view Firefox version

In the Firefox browser, press actions:

After checking "menu bar", exit the customization:

This time Firefox, click "Help", "about Firefox", you know the browser version.

(2) No Firefox updates

Firefox browser in the network state secretly updated, irritating, so to turn off automatic updates, such as, click "Tools", "Options".

Go to the Settings panel, press the operation, turn off automatic Updates.

7. Job (1) Job requirements

A) access to the http://121.193.130.195:8080/login system (account name is the student number, the password is the number 6), after entering the system can see the classmate's git address.

b) Write the Selenium Java webdriver program and test the correct relationship between the number and Git address in the Inputgit.csv table.

(2) Complete the work

The environment has been prepared in the front, and the next thing is done.

A) first export the JUnit test case from Selenium:

I. Open the Firefox browser, enter http://121.193.130.195:8080/,

II. Open Selenium, enter http://121.193.130.195:8080/in BaseURL, click the Red button on the right to start recording (generally click the Selenium button to open the Selenium IDE, it automatically recorded).

III. Fill in the user name and password on the webpage and submit it. (If you have previously filled out, the browser automatically recorded, but also to delete and then re-fill again, or selenium not recorded your input (type) and submit (submit) Action)

The following sex tags, no choice, no use.

Iv. go to the next page: Right-click on the GitHub address to select Asserttext .... If this option is not available, you can right-click on "Show all available command" and select Assettext ....

Why choose Asserttext instead of Verifytext here? Because Asserttext found that the text displayed on the page does not match the expected value, the test case is set to a failed state, the test script stops running, and the test case is set to a failed state when the text displayed on the page does not match the expected value, and the test script continues to run. We certainly want to stop immediately after we find the mistake.

V. Operation completed, selenium IDE such as:

VI. Export the Selenium recorded Java file as a JUnit test case, and in the export to tick the Enable Experimental features option in option:

VII. After you save to a local disk, analyze the contents of the file, which is a single junit test written according to your username and password.

b) JUnit test to write this assignment

To write a set of JUnit test cases on the basis of the exported JUnit tests, let's start with the idea.

I. To test with more than 100 data, be sure to use [email protected] annotations, which are parameterized tests that are designed to test a set of data for the same test case. JUnit last experiment a little bit, do not know or forget to see the link http://blog.csdn.net/huojiao2006/article/details/53671343, entry-level, easy to understand.

II. Given a CSV file to read the data, the above Javacsv jar package is used.

III. The rest is changed on the JUnit test code exported by selenium, note two points.

First:

Remove the "/", if not removed, you will find that after running the program Firefox address bar input is http://121.193.130.195:8080//, this URL must be loaded out ah, because the correct URL is http://121.193.130.195:8080/.

Second:

If your Firefox browser is installed by default address, do not need the following sentence, otherwise add the following code and replace with the address you installed: System.setproperty ("Webdriver.firefox.bin", "C:/Program Files /mozilla Firefox/firefox.exe ");

c) Complete code

The seleniumtest in the following GitHub address is the code you wrote this time:

Https://github.com/DiligentToHappy/learngit

After writing the code, run the JUnit test as follows:

The test results, such as the following have been successful:

When running. Each time Firefox automatically opens, it will appear similar to the following page "Invalid URL", and then normal testing, do not care, because I changed an example test also this (do not know why), anyway you know this is not your example of the problem, is another example also has this problem.

8. Git basic usage

Since I did not understand the use of git, resulting in each upload code is now learning to sell, heart tired, here record:

i) Git bash CD D:\learngit;

II) Add the file to the local repository: git add Seleniumtest.java;

III) Local COMMIT:GIT commit-m "software testing about Trianglekind using JUnit";

IIII) push to remote: Git remote add origin [email protected]:D iligenttohappy/learngit.git;

9. GitHub Code Address

The Seleniumtestjava code in Https://github.com/DiligentToHappy/learngit.

Selenium webdriver Software Test Experiment 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.