DK you are very professional! really helpfull. On 7月1日, 下午9时37分, Dmitriy Korobskiy <[email protected]> wrote: > Jasmine, > > probably, the most powerful way to locate elements is to use XPath. It > could especially help if your elements don't have ids. > > I use it to locate a table with the specific set of headers: > > open_carts = @@browser.table(:xpath, table_xpath("carts")) # the first > table of carts on the page > > # Maps a table type to the XPath expression that selects matching table(s) > def table_xpath(table_type) > case table_type > when "carts" > "//table[thead/tr/th[text()='Cart Name']][thead/tr/th[text()='Created > Date']]" + > "[thead/tr/th[text()='Last Updated > Date']][thead/tr/th[text()='Actions']][thead/tr/th[text()='Status']]" > when "transactions" > "//table" + > "[thead/tr/th[contains(text(), 'Reimbursable > Order')]][thead/tr/th[text()='Document Number']]" + > "[thead/tr/th[text()='Other Document > Number']][thead/tr/th[text()='Action Code']]" # etc. > when "editable transactions" > "//table[thead/tr/th[contains(text(), 'Select for > Deletion')]][thead/tr/th[text()='Actions']]" + > "[thead/tr/th[contains(text(), 'Reimbursable > Order')]][thead/tr/th[text()='Document Number']]" + > "[thead/tr/th[text()='Other Document > Number']][thead/tr/th[contains(text(), 'Action Code')]]" # etc. > else > raise "Unknown table type: {#{table_type}}. Please add mapping to > #{__FILE__}." > end > end > > -- > DK > AIM: DKroot1, Skype: DKroot > > On 7/1/11 4:48 AM, Jasmine wrote: > > > > > I have resolved how to locate the particular refresh link,I used the > > code:ie.div(:text=>"refresh",:index=>2).click,it can work,the first > > value of the index is 2.I don't know why,but I still wonder how to > > locate this table and this td.... > > > On 7 1 , 4ʱ02 , Jasmine <[email protected]> wrote: > >> Who can help me...I don't know how to locate the specfic table...,no > >> id,no name,how can I judge which table is what I want to locate > > >> On 7 1 , 3ʱ33 , Jasmine <[email protected]> wrote: > > >>> Thank you,chaitanya,but there are many refresh links in the page,so I > >>> should locate the table -->tr-->td,if I can locate the specfic td,I > >>> can locate the specfic refesh link.... > >>> thanks a lot ^_^ > >>> On 7 1 , 3ʱ12 , chaitanya <[email protected]> wrote: > >>>> How about browser.cell(:id,"refesh"). It will work > >>>> On Jun 30, 11:17 pm, Jasmine <[email protected]> wrote: > >>>>> Hello > >>>>> I need to locate the table,then locate the tr and td,but the table > >>>>> doesn't have the id and the name,so how to locate the table?I know > >>>>> should use index,unfortunately it doesn't work. > >>>>> there is the part of the code there are 10 tables in the page,I want > >>>>> to locate "refesh" in the row of the table,may be so easy,but I > >>>>> cannot resolve it... > >>>>> <table cellspacing="0" border="0" style="height:63px; width:"> > >>>>> <tbody><tr> > >>>>> <td style=" "> > >>>>> <table cellspacing="0" border="0" > >>>>> style="margin-top:14px; width:112px; padding-left:15px;"> > >>>>> <tbody><tr> > >>>>> <td style="" rowspan="2"></td> > >>>>> <td id="tdrefresh" style="height:28px;" > >>>>> colspan="2"><div align="center" onclick="refresh(this,13652,1,1,0,0)" > >>>>> style="margin-bottom:15px;"><div align="center" > >>>>> style="color:#414141;">refresh</div></div></td> > >>>>> </tr>- 隐藏被引用文字 - > > - 显示引用的文字 -
-- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
