How do I write a Selenium IDE command to verify that the number is present if it increases as I invite more people by email??
For example, the total number of people: 30
Example 1: If I invite 1 person, how do I verify that the total number of people is 31?
Example 2: If I invite 5 people, how do I verify that the total number of people is 35?
Here is the code:
<div style="color:#777; font-size:1.3em; float:right; margin-top:5px;">
Total number of people:
<span style="color:red;">30</span>
I believe you would have to:
Store a value for how many invites you are going to do
Store a value for the expected number of people (ie current plus invites)
Go do the invites
Store a value for the new total number of people
Compare the new number to the expected number
The following does the capturing and comparing of the numbers. You just have to add the part for doing the actual invites.
<tr>
<td>store</td>
<td>5</td>
<td>people_invited</td>
</tr>
<tr>
<td>storeText</td>
<td>//div[contains(text(),'Total number of people')]</td>
<td>original_count_text</td>
</tr>
<tr>
<td>storeEval</td>
<td>parseInt(storedVars['original_count_text'].match(/\d+/))+parseInt(storedVars['people_invited'])</td>
<td>expected_count</td>
</tr>
<tr>
<td>echo</td>
<td>Go invite 5 people</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//div[contains(text(),'Total number of people')]</td>
<td>new_count_text</td>
</tr>
<tr>
<td>storeEval</td>
<td>parseInt(storedVars['new_count_text'].match(/\d+/))</td>
<td>new_count</td>
</tr>
<tr>
<td>verifyExpression</td>
<td>${expected_count}</td>
<td>${new_count}</td>
</tr>
Related
I am working for a project where I need to convert the html that photoshop generates to email client compatible.
Once I receive a psd file, I need to create slices and then generate the html. The problem is that the generated html has tables with rowspan and colspan. I then manually remove these colspans and rowspans and nest tables to achieve the same layout.
My question is, is there a library or something that I can use to automate this task?
Below is just an example, the real problem can include various colspans and rowspans in any specific order.
Example -
PS code ->
<tr>
<td colspan="3">First row 3 columns</td>
</tr>
<tr>
<td>Second row first column</td>
<td>Second row second column</td>
<td>Second row column column</td>
</tr>
I will then have to code this as -
<tr>
<td>First row 3 columns</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>Second row first column</td>
<td>Second row second column</td>
<td>Second row column column</td>
</tr>
</table>
</td>
</tr>
I work for a company who deliver many HTML emails everyday, i'm email HTML developer, and we use Fireworks (CS6, he's not in the CC..) to generate nested tables (some options are to define).
G.
I got this page where I want to run my code:
I got a css with this properties:
<center>
Radicacion Exitosa, Numero Radicacion: 12 - 132263…
</center>
I want to store the "132263" in a variable because I have to copy and paste them in another window, so I want to know if there is a way to only get the number from that tag...specially the "132263" because if I store a Variable Selenium IDE only will get the full text.
Thanks
Using regex in javascript will do this for you:
<tr>
<td>storeText</td>
<td>//center</td>
<td>full</td>
</tr>
<tr>
<td>storeEval</td>
<td>var regex=/\-\s+(\d+)\s+\-/;regex.exec(storedVars['full'])[1];</td>
<td>number</td>
</tr>
<tr>
<td>echo</td>
<td>${number}</td>
<td></td>
</tr>
We're capturing the text from the CENTER tag and then running the regex to grab the number out of it (using the group (\d+) and returning [1]).
I got in my site several amounts of money displayed like this: $5,000
I want to sum all of them and to check some variables. How can I parse and get the number 5000 and use it as a number (summing up, multiplying etc) using Selenium IDE?
You can use storeEval and parse the string into the Number using javascript:
<tr>
<td>storeEval</td>
<td>Number('$5,000'.replace(/[^0-9\.]+/g,""));</td>
<td>amount</td>
</tr>
<tr>
<td>echo</td>
<td>${amount}</td>
<td></td>
</tr>
is there a way to add cells in a row column in html table without adding another table inside the row column
I have attached the image. and here is my code
<tr>
<tbody>
<td>Name</td>
<td><div id="span1">Units</div>
<div id="span2" class="side-border">price</div>
<div id="span2" class="r">value</div>
</td>
</tbody>
</tr>
If you want to have some different structure of your rows, you should check colspan and rowspan. The numbers should add up.
Example
<table border="1px">
<tr>
<td colspan="5">Hello</td>
<td>World</td>
</tr>
<tr>
<td rowspan="2">col 1</td>
<td colspan="4">CENTER</td>
<td>right</td>
</tr>
<tr>
<td colspan="3">Text</td>
<td colspan="3">bottom right</td>
</tr>
</table>
If you were to add the numbers from colspan they add to 6 and rowspan goes to 3. There are some things you have to take care of though. It's a little hard for me to explain now what those are, just try to visualise how you want your table to look, and then follow this:
The table should have the max number of rows
The table should have the max number of columns
rowspan used across table has to add up (more or less)
colspan used across table has to add up (more or less).
Follow that, and after writing the HTML for a few "complex" tables, you'll get the gist of it.
How can I create a variable that has the id from one of my records on the index page?
I can use xpath to get at the anchor I want with:
storeText
//table[#id='districts']//tr/td/a[text()='Fairview Union']
id_of_another_district
but that gets the link name. I want to id for that record, i.e. in the original source code I have:
<tr>
<td>
Fairview Union
<span class='small'>(Select)</span>
</td>
<td></td>
<td></td>
<td></td>
<td class='rightalign'>01/09/2012</td>
<td></td>
<td></td>
<td><img alt="Delete" src="/assets/icons/delete-a77f3c3c125b0817085648f284c98938.png" /></td>
</tr>
and what I want to get and store in a variable in selenium is the record number 31
Using the 'store' command, you can execute javascript code in the 'target' column...
store | javascript{...} | myVar
where the ... is, substitute it with the js you need to return the id.
[Edit from Michael]
I ended up using:
storeAttribute | //*[#class='small']/a[text()='(Select)']/#href | hrefAttr
store | javascript{storedVars['hrefAttr'].replace(/.*\//,'')} | myVar
echo | ${myVar}
myVar now has the ID and I can do things like:
open
/users/change_district/${id_of_another_district}
The answer of sircapsalot (edited by Michael Durrant) is ok, but it's a bit different in my environment, regarding how the javascript is executed: not with javascript{...} So, in my case it looks like this and it works fine:
<tr>
<td>storeAttribute</td>
<td>//html/body/table/tbody/tr[3]/a#href</td>
<td>hrefAttr</td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['hrefAttr'].replace(/.*=/,'')</td>
<td>transportIdVar</td>
</tr>
<tr>
<td>echo</td>
<td>${transportIdVar}</td>
<td></td>
</tr>
The href in my case looks like this:
http://example/local/IntegrationPick?partyId=8080595