iMacros: How to handle missing elements/value for extracting data properly - attributes

I have this code...
VERSION BUILD=8032216
TAB T=1
SET !REPLAYSPEED FAST
SET !ERRORIGNORE YES
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !EXTRACT_TEST_POPUP NO
URL GOTO={{URL}}
TAG POS=1 TYPE=H2 ATTR=* EXTRACT=TXT
SET !VAR0 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_companyname* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:member-address* EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_contact* EXTRACT=TXT
SET !VAR3 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_phone* EXTRACT=TXT
SET !VAR4 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_email* EXTRACT=TXT
SET !VAR5 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_url* EXTRACT=TXT
SET !VAR6 {{!EXTRACT}}
SET !EXTRACT NULL
SET !EXTRACT NULL
ADD !EXTRACT {{!VAR0}}
ADD !EXTRACT {{!VAR1}}
ADD !EXTRACT {{!VAR2}}
ADD !EXTRACT {{!VAR3}}
ADD !EXTRACT {{!VAR4}}
ADD !EXTRACT {{!VAR5}}
ADD !EXTRACT {{!VAR6}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=AdelcookChamber.csv
SET !EXTRACT NULL
When iMacros doesn't find the text/element/ for the attribute class on the page it gives result #EANF# . However it moves my extracted .csv file columns around and leaves the #EANF# at the end of the extracted data in which those elements are found on page, it's actually the ones above the data to be extracted on page that don't have these elements/values.
I'm running this in iMacros browser edition with a play loop set at 8. Anyway to handle this without getting into scripting? I need for it to just mark #EANF# for attribute values that can't be found on page.
----------------------------------------------------------------------------------------
IceD thanks bro for the reply! Can you help me out, since I don't know JavaScript? How would this code look base on my code here?
I cleaned the code up so you can see that it pulls everything fine; except the email(s) and web address(es) when it doesn't find the elements it mis-places into other rows.
I'm playing a loop 8X (number of records on page).
VERSION BUILD=8032216
TAB T=1
SET !ERRORIGNORE YES
SET !REPLAYSPEED FAST
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !EXTRACT_TEST_POPUP NO
FILTER TYPE=IMAGES STATUS=ON
URL GOTO=http://www.adelcookchamber.org/membership-directory/category/advertising/
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_companyname EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:member-address EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_contact EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_phone EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_email EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_url EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=DIV ATTR=CLASS:vs_members_cats EXTRACT=TXT
Wait SECONDS=2
SAVEAS TYPE=EXTRACT FOLDER=* FILE=Adelcook_Chamber.csv

Do this in JavaScript and assign extracted value to a variable.
Use iimGetLastExtract() for that purpose. Each time you have value #EANF# delete it or change it in some ways.

Related

jsf fill title (tooltip) with line-break based on backing-bean

So I dynamically generate a input form from backing bean. One of the dynamically generated element is an image with title value (tooltip). But I couldn't figure out how to add line-break into the title.
I tried "\r\n", "<br/>", "
", all end up showing the same value on the tooltip.
I know if it is an outputText, I could call escape="false" to make it work...but how to do it with the title field?
<img src="img/info.png" title="#{bean.info}"/>
wherea bean.info has value of
"A : apple
B : ball"
but the tooltip end up showing "A : apple
B : ball" instead of on two lines.
Or does anyone have idea how to put an outputText result into the title of an img tag?

Avoid Date field showing as null in XHTML

I am rendering a date field in XHTML using JSF. Since the value in DB is saved as null the date field values is shown as "null" in the UI. How to avoid this null?
My code is given below:
<h:outputFormat value="{0, date, MM/dd/yyyy}"
rendered="#{sysbean.xx.isfeed == '1' or (sysbean.yy== false and sysbean.details.endate!= null)}">
<f:param value="#{sysbean.details.endate}" /></h:outputFormat>
The output I am getting is
Project Name : null
How can I avoid the value coming as "null"?
<f:param value="#{value to check!=null?value when condition is true:
value when condition is false}" />
Checking the null at EL expression,
or in the bean also you can put the inline check for null values.

Cucumber Capybara - Find an element based on attribute's content

My requirement is to check if some particular content (i.e. Id=4540484 in the below example) exists in the onclick attribute on an anchor tag on a page. Can someone help me out please?
<a title="Acrobat PDF File" href="#" onclick="openPop('/example/secure/Screen.aspx?Id=4540484&certdocId=2513235)"><img src="New.gif" align="middle" border="0"></a>
If you want to find an element based on the onclick attribute, you will need to use a css (or xpath) selector.
In your case, you want the css-selector:
a[onclick*="Id=4540484"]
This says to find a link element where the onlclick attribute contains the text "Id=4540484".
You can then use the has_css? method to check if that link is on the page:
#Using an ID that exists will return true
page.has_css?('a[onclick*="Id=4540484"]')
#=> true
#Using an ID that does not exist will return false
page.has_css?('a[onclick*="Id=9999999"]')
#=> false

getelementsbyID inner dt id values

I am extracting data from HTML using Vb Script. This is the HTML code from which am trying to extract the data.
<dl id="overview">
<dt id="overview-summary-current-title" class="summary-current" style="display:block">
Current
</dt>
<dd class="summary-current" style="display:block">
<ul class="current">
<li>
Software Engineer
<span class="at">at </span>
<a class="company-profile-public" href="/company/ABC Systems?trk=ppro_cprof">
<span class="org summary">ABC Systems</span></a>
</li>
</ul>
</dd>
In my previous question, I had asked for a similar doubt. The link is Excel getElementById extract the span class information.
However, in that case, I wanted to extract the information corresponding to the dl id and it also had span id. In this case, I need to extract the information corresponding to the dt id.
In my VB Script, I tried something like this.
Dim openedpage as String
openedpage = iedoc1.getElementById("overview").getElementById("overview-summary-current-title").innerHTML
However, I am getting no output.
I want the output as Software Engineer at ABC systems.
Kindly help me out.
The object returned by getElementById() doesn't have a method .getElementById(), so the following line fails:
.getElementById("overview").getElementById("overview-summary-current-title")
If you don't get any output, not even an error message, you probably have On Error Resume Next somewhere in your script. Please don't use that unless you know exactly what you're doing and have sensible error handling code in place.
Also, the element with the ID "overview-summary-current-title" is this:
<dt id="overview-summary-current-title" class="summary-current" style="display:block">
Current
</dt>
So you couldn't possibly extract the text "Software Engineer at ABC systems" from that element.
Try selecting the first <ul> tag from the element with the ID "overview", and then use the innerText property instead of the innerHtml property:
Set ie = CreateObject("InternetExplorer Application")
ie.Navigate "..."
While ie.Busy : WScript.Sleep 100 : Wend
Set e1 = ie.document.getElementById("overview")
Set e2 = e1.getElementsByTagName("ul")(0)
WScript.Echo e2.innerText

h:selectOneRadio renders all select items in one line, how to render each in new line?

I have a selectOneRadio tag and all radio button options are displayed on one row. How can I make it one option per row/line?
To learn about tag's behavior and all of its available attributes, a good starting point is the tag documentation. Here's an extract relevance from the <h:selectOneRadio> tag documentation:
[...]
Encode Behavior
Render a "table" element. If the "styleClass" is specified, render the value of the "styleClass" attribute as the value of the "class" attribute on the "table" element. If the "style", "border" attributes are specified, pass them thru and render their values as the "style" and "border" attributes on the "table", respectively. If the "layout" attribute is specified, and its value is "pageDirection", render the children elements vertically, otherwise horizontally, in the table. If any of the children are an instance of SelectItemGroup, render them as a nested table. Each of the children are ultimately rendered as follows. Render an "input" element of "type" "radio" for each child component. Render the "name" attribute on the "input" element with the value of the clientId of the component. Render an "id" attribute on the "input" element. Each "id" value must be unique. If the current SelectItem.isDisabled() returns true, render "disabled" as the value of the "disabled" attribute.
[...]
Note the emphasis. There's your answer.
<h:selectOneRadio ... layout="pageDirection">

Resources