[Pick]selenium-ide Edit command

Source: Internet
Author: User

----//Edit commands

The script that selenium for us is not 100% in line with our needs, so editing the recorded script is an essential work.

1. Edit a line of commands or comments.

Select a row of commands under the Table tab, which consists of the command, Target, and value three parts. You can edit these three parts of the content.

2. Insert the command.

Right-click on a command and select the Insert New Command command to insert a blank and edit the blank line process.

3. Inserting annotations

In the same way, right-clicking the "Insert new comment" command inserts the blank line of the note, the bank's content is not executed, which helps us to better understand the script, and the inserted content is displayed in purple font.

4. Move commands or annotations

Sometimes we need to move the order of a certain line of command, we just need to click the left mouse to drag to the corresponding position.

----//Record our first script

Our recording process:

With Firefox, open a new tab-----Enter Google Web address (http://www.google.com.hk/)----in the search box type: Selenium----Click on the "Google search" button.

Note: Note The Record button to turn on and off the red circle on the Selenium IDE panel.

Recorded script:

----//debug scripts

1. Set breakpoints.

To set a breakpoint, first select a line of command, click the right mouse button, select the "Toggle Breakpoint" command in the drop-down menu, click the "Run" button, the script will run to the breakpoint stop. Debugging scripts with the debug function of the Myecilpse students understand!

2. Debug scripts with Page source code

In many cases, debugging automation test cases can not be separated from the view page source code, we may use the Firefox Firebug tool, about Firebug installation (Browser menu bar---Tools---view components---search firebug---Install and restart the browser.)

Such as: we are unsure or want to get the properties of Google search button. Right-click on the button---view the element

You can see the button code in the Firebug tool that opens under the browser.

3. Location Assist

When the Selenium IDE records a script, it stores additional information that allows the user to pick a locator in another format instead of the default format locator, which is useful for learning locators.

We can choose other commands instead of the "name=btng" command, and of course the script will still work.

Through learning, I believe that we have selnium the basic use of the IDE, in order to make selenium more powerful, in fact, selenium also provides a good ability to expand.

----//user extension

User extensions are the use of JavaScript files to create custom features, add new features, and typically such extensions are custom commands, but extensions are not limited to commands.

Here are some columns of extensions: http://wiki.openqa.org/display/SEL/Contributed+User-Extensions

1. Below we use the extended method to generate a user random number

In order to use the user extension, we need to create a file and of course we can download it from the link above. File name is: user-extention.js

 //Generate random numbersSelenium.prototype.doStoreRandom =function (variableName) {random = Math.floor (Math.random () *10000000); Storedvars[variablename] = random;}
// pop-up box Selenium.prototype.doDisplayAlert = function (value, varName) {alert (value);}
//function (Locator) { var dates = new Date (); var day = Dates.getdate (); if (Day < ten) {day = ' 0 ' + day;} month = Dates.getmonth () + 1; if (Month <) {month = ' 0 ' + month;} var year = Dates.getfullyear (); var prettyday = day + '/' + month + '/' + year; this.dotype (Locator, ' dddddd ');}

Copy the above code into a notepad and save it as a: User-extention.js file

Import this file in the selenium IDE, such as:

When the file is selected, click the "OK" button. You must close and restart the selenium IDE so that the extension file is read. Any extension changes require that the selenium IDE be shut down and restarted.

2. Convert Code Form

Select Format under the Options menu to allow you to select a language to protect and warrior test cases. The default is HTML format.

If you are using selenium RC to run the test case. This feature can help you translate your test case into a programming language.

We can select "file"----Export test case as ... To convert the language format we need. For specific examples, please refer to "Selenium RC environment Building"

3. Perform selenium IDE tests on different browsers.

The Selenium IDE runs only on Friefox, but it can be run on other browsers through automated tests developed by the Selenium IDE. Just use a simple command to wake up the Selenium RC server.

If the browser is not directly supported, you can still run the selenium test case on the browser by using the "*custom" run mode.

Cmd=getnewbrowsersession&1c:\Program files\mozilla firefox\mybrowser.exe&2=http://  fnng.cnblogs.com   

The following code:

Package com.example.tests;
Import Java.util.regex.Pattern;
New Defaultselenium ("localhost", 4444, "*chrome", http://fnng.cnblogs.com/);
You can replace the previous line of code with the following line of code
Cmd=getnewbrowsersession&1c:\Program files\mozilla firefox\mybrowser.exe&2=http://  fnng.cnblogs.com   
If it is IE browser, you can directly modify the browser name, the code is as follows:
*iexplore ", http://fnng.cnblogs.com/); This is a much simpler approach.
        Selenium.start ();     }
@Test throws Exception { Selenium.open ("/"); Selenium.click ("Id=homepage1_homepagedays_dayslist_dayitem_0_daylist_0_titleurl_0"); Selenium.waitforpagetoload ("30000"); }
@After throws Exception {selenium.stop ();}}

How to configure the Java environment to verify a piece of code for my face, please refer to my "Selenium RC Environment building "

Note : If you start your browser this way, you must manually configure your browser to use selenium Server as a proxy, usually this simply means opening your browser parameters file and indicating "localhost:4444" as the HTTP proxy. However, the instructions from different browsers may be completely dissimilar, which requires more detail from your browser's support documentation.

================================================

This article refers to: http://luyongxin88.blog.163.com/blog/static/9255807201181114747437/drool of the piglet (his blog test article a lot, is I study example)

[Pick]selenium-ide Edit command

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.