We know that,QtpProvides object spy tools, Object Library recording functions, or descriptive programming to quickly identify objects,
To some extent, scripts can be generated in batches. Correspondingly, I am thinking about such a good tool andTechnologyWhy is watir not supported?
Maybe in the futureAutomationStudents and the watir development team can work hard to meet this requirement.
Another question is thrown out. Do we have to find and select the objects we want to operate in so long code to prepare the watir script?
Give me a simple summary,
1. Similar to the object spy toolMicrosoftThe tool ie developer toolbar for developers can be used to indicate
Object. Find the corresponding attribute in attribute view.
2. Similar to descriptive programming,
Run IRB in cmd,
For example, puts 2 + 2
Print 4. You can use commands to achieve what you see is what you get,
For example:
Require 'watir'
Ie = watir: IE. Start ('HTTP: // localhost: 8080 ')
Ie. show_all_objects
Result:
----------- Objects in page -------------
Text name = Name id =
For example: IE. text_field (: name, 'name'). Flash
Result: The webedit box of the control object is highlighted in yellow.
What's more, when I move the mouse focus to a webedit,
Then:
IRB> puts ie. show_active
Text name = Name
Id = value =
Alt = src =
Innertext =
=> Nil
Here, watir will help us identify the current active object.
For buttons andOthersObject. You can also use the tab key to move the focus,
Use Alt + TAB to activate the IRB window and use the same show active method.
Another example is:
IRB> puts ie. show_active
Submit name = submit_logon
Id = value = Login
Alt = src =
Innertext =
=> Nil
IRB> ie. text_field (: name, 'name'). Set ('test1 ')
=> Nil
You can refer to the watir APIWebThe Edit object is used to clear and Append content.
In addition, the HTML of the current IE Object can be output.
IRB> puts ie.html
<H1>
<P align = center> Create the First Job </P> <Table cellspacing = 0 cellpadding = 3 border = 0>
<Tbody>
<Tr>
<TD align = middle width = "40%">
<Form ID = job name = Job Action = job method = get> <input type = hiding value = 22909012 name = session> </input>
<Table cellspacing = 0 cellpadding = 3 border = 0>
<Tbody>
Or only output text:
IRB> puts ie. Text
Create the First Job
Please create the first job
Make it a background job
If you make this job a background job, it will be a job that accumulates time when you're not doing any specific task. You'll start it in the morning,
Do your work-starting and pausing other jobs-Then stop it when you're done for the day.
Each time you pause another job, the background job will resume accumulating time.
If you don't have a background job, you'll have to manage time more explicitly.
=> Nil
IRB (main): 024: 0>
Index can be used when there is only one feature object on the page, for example:
Ie. text_field (: Index, 1). Set ('TestingFor bugs ')
IRB> ie. Button (: Index, 1). Click
=> Nil
You can use the show_all_objects method to display all objects on the page.
You can also display a specific type of object, such:
Show_images show all the images in the document
Show_spans show all the span tags in the document
Show_labels show all the labels in the document
Show_links show all the links in the document
Show_divs show all the DIV tags in the document
Show_frames show all the frames in the document
Show_forms show all the forms in the document
Here, we use IE. show_table as an example.
IRB> ie. show_tables
Found 8 tables
1 id = rows = 1 columns = 3
2 id = rows = 2 columns = 1
3 id = rows = 3 columns = 1
4 id = rows = 2 columns = 1
5 Id = rows = 3 columns = 1
6 id = rows = 1 columns = 1
7 id = rows = 3 columns = 1
8 id = recent_records rows = 2 columns = 1
=> Nil
We can use the flash method to identify an object,
IRB> ie. Table (: ID, 'recent _ records '). Flash
You can also display only the HTML code of a specific table,
IRB> puts ie. Table (: ID, 'recent_records').html
<Table id = recent_records cellspacing = 0 cellpadding = 3 width = "66%" align = center border = 1> <tbody>
<Tr bgcolor = #66 FFFF>
<TD align = middle colspan = 4> recent records </TD> </tr>
<Tr bgcolor = # ccffff>
<TD> testing for bugs </TD>
<TD> 10: 05 PM </
<TD> 0.00 hours </TD>
<TD> <B> running </B> </TD> </tr> </tbody> </table>
Here we can use the ruby built-in function to_a to output an array of Row Records,
IRB> IRB (main): 009: 0> my_array = ie. Table (: ID, 'recent _ records '). to_a
=> [["Recent records"], ["testing for bugs", "10: 05 PM ",
As shown above, the show_xxx method is used to enumerate the same feature objects,
Do you feel the method similar to qtp: Create descr resume ption.../MIC class = 'webobject?
Similarly, you can even modify the underlying show_xxx code to generate scripts in batches,
For example, generate a text field operation script with the entered values...