Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Recommendation of automatic selection of weblist and webcheckbox in QTP

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Let's first recommend a way to automate weblist and webcheckbox in QTP, on the grounds that many online methods are not feasible or too complex. In fact, things are often very simple, but people who think about him always think that it is very complicated, so there are so many complicated things.

Don't talk too much nonsense, tell the principle:

Since there is no specific code on this laptop, we can only use memory plus word of mouth to describe the choice of how to automate weblist, and the webcheckbox method is the same.

Generally speaking, when we choose to record a weblist, the experience is as follows:

Browser (a page). Page (a page). Frame (a frame). Weblist (a drop-down selection table). Select specific value

For weblist, it is generally viewed in Objectspy, and it will generally correspond to "value 1; value 2; value 3." under attributes such as "all items". Here, we can use this complete value range to automatically select the reference value. We can first use getROproperty ("all items") to extract the value segment, and then we need to figure out how to divide the complete value segment into several parts and store it into an array variable for us to use.

I believe that most readers have thought of using the split function to split this complete range of values. Yes, we are using this handsome function, and we can write split (browser) .page (page) .frame (frame) .weblist (a drop-down selection table) .getROproperty ("all items") like this. " What we need to get each small piece in this value range is the value (I won't elaborate on what I don't understand about the split function, please don't understand the information on the children's shoes reference network). After dividing it, we can put it into an array variable, and then all we need to do is how to randomly select the value of the array.

In QTP, we can use Randomnumber (lower bound, upper bound) for random values, but the most important thing left is how do we get the upper bound of the array? At this point is very simple ~ that is the ubound function! Yes, a small function becomes the key for us to do automatic valuing. (is it actually very simple to say something a little complicated here?)

Here's what we do:

Dim rand_select

Rand_select=split browser (a page) .page (a page) .frame (a frame) .weblist (a drop-down selection table) .weblist ("all items"), ";",-1 all items 1

Browser (a page) .page (a page) .frame (a frame) .weblist (a drop-down selection table). Select randomnumber (0jue ubound (rand_select))

In this way, we can simply realize the automatic choice of weblist!

The automatic selection method for webcheckbox is the same.

I hope it will be helpful to you, thank you ~ in the next Causeless

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report