Hello Anna,
Works perfect!! so simple and brilliant
The code looks like this:
ie.div(:id, 'resultsList').lis.each do |element|
puts element.link(:url ,/job/).text
puts element.span(:class, 'jobSearchJobListedDate').text
puts element.ps[1].text.to_s
end
Only 2 problems left:
1). How can I get the text out of <em> tag for each div? that tag
seems as not supported.
The xpath works great but for the <em> tag only - ie.element_by_xpath
("//em").innerText
<div id=resultsList class=><ol id="searchResultsList"><li><span
class="jobsearchNumber">1<input type="checkbox" name="chkJob"
onClick="UpdateSelectedItems();" value="16015024"></input></
span><div><h2><a href="/job/file-migration-b-analyst-b/gold-coast/
16015024/">File Migration <span class="highlight">Analyst</span></a>
<em>TLC ITStaff</em></h2>
2). Is there a generic method/procedure to iterate for all results
page/s?
Follows the html:
<span class="frame"><span class="frameStart"><i></i></span>
<div class="contentBox firstBox">
<h1><span
id="ContentInclude_YourQuery1_ResultsLabel"><strong>1</strong> -
<strong>2</strong> of <strong>2</strong> </span><span>jobs containing
<strong>test analyst</strong> in <strong>Gold Coast</strong></span>
or
check if the 'Next' exists (how can I handle a scenario with no
'Next' (just one page with or no results at all):
ie.element_by_xpath("//strong[contains(text(),'Next')]").click (this
works but how can I handle just one page or no results at all)
<div class='searchPagination'><dl class='jobSearchPagination'>
<a class='nextPage btn pinkbtn_small' href="javascript: PageTo
(2)"><strong>Next<img src='/general_ID_items/images/other/
bullet_search_white_small.gif'></strong></a><dt>Page</dt><dd
class='currentPage'><span>1</span></dd>
<dd><a href="javascript: PageTo(2)">2</a></dd>
<dd><a href="javascript: PageTo(3)">3</a></dd>
<dd><a href="javascript: PageTo(4)">4</a></dd>
<dd><a href="javascript: PageTo(5)">5</a></dd>
<dd><a href="javascript: PageTo(6)">6</a></dd>
<dd><a href="javascript: PageTo(7)">7</a></dd>
<dd><a href="javascript: PageTo(8)">8</a></dd>
<dd><a href="javascript: PageTo(9)">9</a></dd>
<dd><a href="javascript: PageTo(10)">10</a></dd></dl></div>
</div>
Thank U all for the helpful support
Guy
On Sep 17, 12:37 am, Anna Gabutero <[email protected]> wrote:
> On Wed, Sep 16, 2009 at 09:04:31AM -0700, Guy wrote:
>
> > to all watir wiz,
>
> > Would love to get support:
>
> > puts ie.div(:id, "resultsList").text could be used to get a long
> > (correct) list all the right divs. I would like to get the the values
> > (Test Analyst Load Runner', 'Fri 11 Sep', 'Excellent 12 Month fixed
> > Term role for a Test Analyst with strong Load Runner Experience - One
> > of the largest testing teams in Brisbane is expanding' and 'Hudson')
> > as separated using:
>
> > puts ie.span(:class, "jobSearchJobListedDate").text
> > puts ie.span(:class, "highlight").text
> > puts ie.element_by_xpath("//em").innerText
>
> > and write them into csv file.
>
> > I can I create a divs collection and run the above on each div?
>
> > I also tried the next:
> > ie.elements_by_xpath("//d...@id='resultsList']").each do |elem|
>
> > Is there a way to run elem.span(:class, "highlight").text or am I
> > wrong?
>
> > Cheers,
> > Guy
>
> XPath is overkill. Your sample HTML has an ordered list of results, so
> why not iterate through it?
>
> ie.div(:id, 'resultsList').lis.each do |element|
> puts element.span(:class, 'highlight').text
> end
>
> Note how these selectors can be chained. ie.div(:id, 'resultsList').lis
> will return only <li> elements inside the named div, then
> element.span(:class, 'highlight') will return the matching <span> within
> one particular <li>. For more details, refer to Watir API
> documentation (http://wtr.rubyforge.org/rdoc/).
>
> I'll let you fill in the rest.
>
> HTH,
> Anna
>
>
>
> > but I would like to get
> > On Sep 14, 11:29 pm, Guy <[email protected]> wrote:
> > > Hello All,
>
> > > Thanks for the help so far. I still face a problem to retrieve the
> > > next info ('Test Analyst Load Runner', 'Fri 11 Sep', 'Excellent 12
> > > Month fixed Term role for a Test Analyst with strong Load Runner
> > > Experience - One of the largest testing teams in Brisbane is
> > > expanding' and 'Hudson') from the next html:
>
> > > I would like to create a list of all jobs from a given page (there are
> > > ~20 links per page) so this is just example values.
>
> > > <div id=resultsList class=><ol id="searchResultsList"><li><span
> > > class="jobsearchNumber">1<input type="checkbox" name="chkJob"
> > > onClick="UpdateSelectedItems();" value="15998998"></input></
> > > span><div><h2><a href="/job/b-test-b-b-analyst-b-load-runner/brisbane/
> > > 15998998/"><span class="highlight">Test Analyst</span> Load Runner</
> > > a>
> > > <em>Hudson</em></h2><span
> > > class="jobSearchJobListedDate">Fri 11 Sep</span><div><p>Excellent 12
> > > Month fixed Term role for a Test Analyst with strong Load Runner
> > > Experience - One of the largest testing teams in Brisbane is
> > > expanding.</p><span class="taxonomy"><a href="javascript:ClassTree
> > > ('catindustry=1215')">I.T. & T</a> > <a
> > > href="javascript:ClassTree
> > > ('catoccupation=1491&catindustry=1215')">QA/Testers</a></span></
> > > div><h3>Brisbane</h3><h3></h3></div></li><li><span
> > > class="jobsearchNumber">2<input type="checkbox" name="chkJob"
> > > onClick="UpdateSelectedItems();" value="15995612"></input></
> > > span><div><h2><a href="/job/b-test-b-b-analyst-b/brisbane/
> > > 15995612/"><span class="highlight">Test Analyst</span></a>
> > > <em>Beyond Recruitment Pty Ltd</em></
> > > h2><span class="jobSearchJobListedDate">Fri 11 Sep</span><div><p>Test
> > > Analyst contract opportunity at a leading company based in Brisbane
> > > CBD</p><span class="taxonomy"><a href="javascript:ClassTree
> > > ('catindustry=1215')">I.T. & T</a> > <a
> > > href="javascript:ClassTree
> > > ('catoccupation=1491&catindustry=1215')">QA/Testers</a></span></
> > > div><h3>Brisbane</h3><h3></h3></div></li><li><span
> > > class="jobsearchNumber">3<input type="checkbox" name="chkJob"
> > > onClick="UpdateSelectedItems();" value="15956235"></input></
> > > span><div><h2><a href="/job/peoplesoft-b-test-b-b-analyst-b/brisbane/
> > > 15956235/">PEOPLESOFT <span class="highlight">TEST ANALYST</span></a>
> > > <em>Integrated Business Technologies Pty
> > > Ltd</em></h2><span class="jobSearchJobListedDate">Fri 04 Sep</
> > > span><div><p>Immediate requirement for an experienced PeopleSoft test
> > > analyst across HR/Payroll</p><span class="taxonomy"><a
> > > href="javascript:ClassTree('catindustry=1215')">I.T. & T</a> >
> > > <a href="javascript:ClassTree
> > > ('catoccupation=1491&catindustry=1215')">QA/Testers</a></span></
> > > div><h3>Brisbane</h3><h3></h3></div></li><li><span
>
> > > Cheers,
>
> > > Guy
>
> > > On Sep 11, 6:14 pm, Wesley Chen <[email protected]> wrote:
>
> > > > For the comment below:
> > > > $ie.element_by_xpath("//img[contains(@src, 'report_delete.png')]").click
> > > > It can locate an image element, which has src attributes, for the
> > > > "report_delete.png" is just part of the src.
>
> > > > I think it can help you.
>
> > > > Thanks.
> > > > Wesley Chen.
>
> > > > On Fri, Sep 11, 2009 at 6:03 PM, Guy <[email protected]> wrote:
>
> > > > > Hello Orde,
>
> > > > > It sure works but I should have ask my question better.
>
> > > > > The "peoplesoft-b-test-b-b- analyst-b/brisbane" can't be hard coded
> > > > > into the xpath as it changes.
>
> > > > > is there a way to use regexpr in the xpath? I think that /job/ is
> > > > > always returns.
>
> > > > > Cheers,
>
> > > > > Guy
>
> > > > > On Sep 11, 9:26 am, orde <[email protected]> wrote:
> > > > > > You should take a look athttp://wiki.openqa.org/display/WTR/XPath.
>
> > > > > > Something like this should work:
>
> > > > > > puts browser.link(:xpath,"//a...@href='/job/peoplesoft-b-test-b-b-
> > > > > > analyst-b/brisbane/15956235/']/").text
>
> > > > > > Hope it helps.
>
> > > > > > On Sep 10, 8:32 am, Guy <[email protected]> wrote:
>
> > > > > > > Hi Orde,
>
> > > > > > > It is very helpful and I already put that in my script.
> > > > > > > I would appreciate help with the next (xpath)
>
> > > > > > > I try to get the "PEOPLESOFT TEST ANALYST" and the date 'Fri 04
> > > > > > > Sep'
> > > > > > > using xpath without getting the right value. Any ideas would be
> > > > > > > welcome.
>
> > > > > > > <div id=resultsList class=><ol id="searchResultsList"><li><span
> > > > > > > class="jobsearchNumber">1<input type="checkbox" name="chkJob"
> > > > > > > onClick="UpdateSelectedItems();" value="15956235"></input></
> > > > > > > span><div><h2><a
> > > > > > > href="/job/peoplesoft-b-test-b-b-analyst-b/brisbane/
> > > > > > > 15956235/">PEOPLESOFT <span class="highlight">TEST
> > > > > > > ANALYST</span></a>
> > > > > > > <em>Integrated Business Technologies
> > > > > > > Pty
> > > > > > > Ltd</em></h2><span class="jobSearchJobListedDate">Fri 04 Sep</
> > > > > > > span><div><p>Immediate requirement for an experienced PeopleSoft
> > > > > > > test
> > > > > > > analyst across HR/Payroll</p><span class="taxonomy"><a
> > > > > > > href="javascript:ClassTree('catindustry=1215')">I.T. & T</a>
> > > > > > > >
> > > > > > > <a href="javascript:ClassTree
> > > > > > > ('catoccupation=1491&catindustry=1215')">QA/Testers</a></span></
> > > > > > > div><h3>Brisbane</h3><h3></h3></div></li><li><span
>
> > > > > > > Many Thanks,
>
> > > > > > > Guy
>
> > > > > > > On Sep 10, 2:21 am, orde <[email protected]> wrote:
>
> > > > > > > > This will give you the number of links:
>
> > > > > > > > browser = [your browser of choice]
>
> > > > > > > > puts browser.links.length
>
> > > > > > > > -------
>
> > > > > > > > To create the loop:
>
> > > > > > > > while browser.image(:src,
> > > > > > > > /bullet_search_white_small.gif/).exists?
> > > > > > > > puts 'exists'
> > > > > > > > sleep 2
> > > > > > > > browser.refresh
> > > > > > > > end
>
> > > > > > > > Hope that helps.
>
> > > > > > > > orde
>
> > > > > > > > On Sep 9, 7:56 am, Guy <[email protected]> wrote:
>
> > > > > > > > > Hello All,
>
> > > > > > > > > I'm New with watir but appreciate how good it is.
> > > > > > > > > I'mlookingfor a way to count all PageTo(*) elements or to loop
> > > > > until
> > > > > > > > > the bullet_search_white_small.gif ('Next' image) doesn't
> > > > > > > > > exist in
> > > > > the
> > > > > > > > > page
> > > > > > > > > Follows is the html code from the site
> > > > > > > > > <div class='searchPagination'><dl class='jobSearchPagination'>
> > > > > > > > > <a class='nextPage btn pinkbtn_small' href="javascript: PageTo
> > > > > > > > > (4)"><strong>Next<img src='/general_ID_items/images/other/
> > > > > > > > > bullet_search_white_small.gif'></strong></a><dt>Page</dt>
> > > > > > > > > <dd><a href="javascript: PageTo(1)">1</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(2)">2</a></dd><dd
> > > > > > > > > class='currentPage'><span>3</span></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(4)">4</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(5)">5</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(6)">6</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(7)">7</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(8)">8</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(9)">9</a></dd>
> > > > > > > > > <dd><a href="javascript: PageTo(10)">10</a></dd></dl></div>
> > > > > > > > > </div>
> > > > > > > > > Cheers,
> > > > > > > > > Guy
>
> > ___________________________________________________________________________
> > _________
> > Use the link below to report this message as spam.
> >https://lavabit.com/apps/teacher?sig=738213&key=3281534178
> > ___________________________________________________________________________
> > _________
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---