18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to capture text from html with no Id's?

b1833b1833 Members
edited September 2011 in Sahi - Open Source
Given the following html:

<h5>Type of Entity</h5>
<p>Corporation</p>
<p>Incorporated: July 2008, UT</p>
<h5>Contact Information</h5>
<span class="employees" itemprop="employees">
<span itemscope itemtype="hxxp://schema.org/Person">Primary Contact: 
<span itemprop="name" class="person">Ms. person1 </span>
 <span itemprop="jobTitle" class="person">(Office Manager)</span></span>
<span itemscope itemtype="hxxp://schema.org/Person">
<span itemprop="name" class="person">Mr. person2 </span>
 <span itemprop="jobTitle" class="person">(Company Contact)</span></span>
<span itemscope itemtype="hxxp://schema.org/Person">
<span itemprop="name" class="person">Mr. person3, DDS </span></span></span>
<h5>Business Category</h5>


(please note: i replaced http with hxxp so it would not be a link in the posting.)

I want to scrape the following:
Primary Contact: Ms. person1 (Office Manager)
Mr. person2 (Company Contact)
Mr. person3, DDS

Basically the list that comes before the next h5 tags.

I can't figure out how to capture these. Is there a way to capture the "employee" class?

Any help is appreciated.

Thanks!

OS X 10.6.7
Firefox 3.6.31
Sahi
Version : V3.5
Build : 2011-04-04

Comments

  • Hi b1833,

    You can try with these:

    _span("(Office Manager)").classList;
    _getText(_span("employees"));

    Let me know if this helps.

    Regards
    Sumitra
  • Perfect! I need to review what I did yesteday.
    I thought I tried this one:

    _getText(_span("employees"));

    but when pasted your code into my script the above line worked flawlessly.

    Thank you very much.
This discussion has been closed.