开发者

Manual test conversion to Selenium RC

There is manual Test case. We need to check the following.

Action

Check Promo Links.

Expected Results

Up to four links are开发者_JAVA技巧 displayed at the bottom of the app. The links are divided by bars "|"

HTML Code ..

< html>
< div class="xxx-module-content">
< div class="xxx-content-block">
< div style="float: left; margin: 0pt 10px 15px 0pt; padding: 0px;"> <a from="hp_xxx" href="" >< img  alt="South Miami" style="border: 0px none;" src="" title="South Miami" height="97" width="130" >< /a> </ div>< !-- BR -->< img  src="" title="xxx Weather" height="16" width="125" >< br>< !-- BR -->< br>< !-- BR -->< a title="South Miami" href="" from="hp_xxx" >South Miami< /a>< br>< !-- BR -->Photo shot from Key Biscayne looking at Miami< br>By: Jimperdue21< br>< div style="clear: both; width: 100%; margin-bottom: 15px;">< a title="Submit Photo" from="hp_xxx" href="" >Submit Your Photo< /a> &nbsp;| &nbsp;< a title="Submit Video" from="hp_xxx" href="" >Submit Your Video< /a>< /div>
< /div>
< /div> 
</html>

Please suggest what logic should be used here through JAVA+selenium RC.

Thanks a lot.


you can do this in number of ways. [ you did not give enough info.]

do you want to check the no. of Links ? or the links with particular Text ?

according to my understanding, you just wanted to count whether minimum of 4 links displayed at the bottom or not(text doesn't matter)

  • you should not depend on "|" devider. this comes under styling/formatting (if you want do the testing based on "|" character, you can do. but it is not usual)

  • you should find out a) are all the links you want to check have ant Id's / names declared : if so you can look for it straight. if not,

    b) all of the links have the same parent with ID or Name or Any Particular Tag: if so, make use of

String numberOfLinks = selenium.getEval("var parent = window.getElementsById('parent tag Id');parent.getElementsByTagName('a').length");// gives no.of links in that particular parent (usually a tage) element.

selenium.getEval("window.getElementsByTagName('parent tag name');") //use this also same as above.

another approach : 1) for(String link : selenium.getAllLinks() ) { //returns all the links on the current page //here you could do according to your app. requirement. ex... }

---if you want to check the links(not the number of links), better use that with Text as you know that text.

selenium.isElementPresent() or selenium.isTextPresent(); above you can use Locator either ID if not "link=text"

i hope one of these will help you . if not post your code (HTML)


Use isElementPresent with appropriate locators on all four links.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜