I am trying to check that the text "AUTOTEST" is present somewhere in my HTML table "tableTest".
In selenium IDE, i put this code :
<tr>
<td>verifyTextPresent</td>
<td>//table[#id='tableTest']</td>
<td>AUTOTEST</td>
</tr>
Here is the code of the HTML table :
<table id="myTable">
<tr>
<td>AUTOTEST</td>
<td>TEST</td>
</tr>
<tr>
<td>UOI</td>
<td>TEST</td>
</tr>
</table>
But the assertion always return false whereas text is well present in the table.
Which command can i use to check that text is present in my table ?
I think the reason for this is that you're trying to verify one bit of text using the entire table as a locator, rather than the specific section that contains the text you're looking for, as a result it isn't matching because you have other content within the table, and your verify step is looking for an exact match. You'd need to put in wildcards around AUTOTEST in your selenium script, that way it will just look to make sure that it is present somewhere within the table.
Script and log testing against the HTML code you provided for the table.
<tr>
<td>verifyText</td>
<td>css=table</td>
<td>*AUTOTEST*</td>
</tr>
[info] Playing test case Untitled
[info] Executing: |verifyText | css=table | *AUTOTEST* |
[info] Test case passed
VerifyTextPresent is depracted, VerifyText will do what you want:
<tr>
<td>verifyText</td>
<td>//table[#id='myTable']</td>
<td>*AUTOTEST*</td>
</tr>
The other thing to note is the text is the FULL text, so in this case you need to use a glob and use the * which serves as a wildcard.
Note: by the way you could also just specify the id (and not the full xpath) like this:
<tr>
<td>verifyText</td>
<td>myTable</td>
<td>*AUTOTEST*</td>
</tr>
Related
I want to generate the filename parameter of the captureEntirePageScreenshot command in Selenese through javascript. Is that possible?
The scenario is that I want to take a screenshot of every page that is opened, and the name of the webpage is generated dynamically and encodes some information.
Combine it in javascript:
<tr>
<td>storeEval</td>
<td>Date.now()</td>
<td>timestamp</td>
</tr>
<tr>
<td>storeEval</td>
<td>"SomePrefixScreenShot" + storedVars['timestamp']</td>
<td>filename</td>
</tr>
<tr>
<td>echo</td>
<td>${filename}</td>
<td></td>
</tr>
This can be done by using the "storeEval" command to generate the name, followed by the original "captureEntirePageScreenshot" command that uses the variable defined in "storeEval" as the parameter.
I hope it saves someone 30 mins :)
I am hoping I can get some help, I need to know how to accomplish something but not sure how as I am new to selenium commands.
I tried the following:
storeEval
javascript{window.document.getElementById('myDiv');}
myResult
then
gotoIf
${myResult} == false
lblWhereToGoIfStyleDisplayIsNotVisible
This does not give me what I want as I always have the div in my page, even if the style = display : none.
What I need is to get the display property of the style of the div and check that value to see if none to then jump to the lblWhereToGoIfStyleDisplayIsNotVisible label
I was thinking I need to use storeAttribute or storeElementPresent but not sure how to implement properly to get result needed.
Any help is appreciated, thanks in advance.
I finally got my script working on my own as I was getting no quick responses, I tried many other type of searches about the gotoIf, css attributes, etc... and found one link at
http://sysmagazine.com/posts/190358/
which helped alot...
here is the final code if someone is interested in knowing how to get a div, display property value, store it, compare it to == NONE (if div is hidden) and go to the next label (test location in the script) in order to continue testing (setting dropdown values)....
this allows me to set values only if the div exists and is visible meaning the dropdown will have selections
This allowed me also to define 1 script for multiple possible test cases, just by changing the url based on the test I want to have.
Cheers!
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>window.getComputedStyle(window.document.getElementById('trProtection'),null).getPropertyValue('display');</td>
<td>myResult</td>
</tr>
<tr>
<td>echo</td>
<td>javascript{storedVars['myResult'];}</td>
<td></td>
</tr>
<tr>
<td>gotoIf</td>
<td>storedVars['myResult'] == "none"</td>
<td>lblDivision</td>
</tr>
<tr>
<td>select</td>
<td>id=selProtection</td>
<td>label=DISABILITY</td>
</tr>
<tr>
<td>label</td>
<td>lblDivision</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
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'm writing test cases for a webpage that has a table as the main focus of the page. I'm checking that the page contains a new entry via the Page Should Contain fucntion, I then want to find the xpath for this element. I am doing this because each entry is added to the end of the table so I cannot set a static xpath for it because I don't know how many entries will be added between each run of this particular test.
Thanks in advance.
<table class="fw-table">
<thead>
<tr class="affix-header">
<th class="columnwidth-description">Email</th>
<th>Account</th>
<th>Signed up</th>
<th>Number of invalid attempts</th>
</tr>
</thead>
<tbody>
<tr>
<td>devtest</td>
<td>Account</td>
<td>true</td>
<td>0</td>
</tr>
<tr>
<td>test#testing.com</td>
<td>Account</td>
<td>true</td>
<td>1</td>
</tr>
search for: xpath=//body/div[2]/div/div[2]/div[2]/div/div/table/tbody/tr[1]/td[1]
If you need to verify that last table row contains certain text you can use the Page Should Contain Element keyword and provide an xpath locator which will find the last table row containing your text:
Page Should Contain Element xpath=//table[#class="fw-table"]//tr[last()]//td[contains(text(),'bottomline')]
I'm having difficulty selecting a window that pops up using Selenium IDE. I've tried
selectWindow(title)
and
selectPopup(title)
but they don't seem to work. Once the window is selected, the
verifyTitle(title)
works just fine, so I started doing some testing and the tests were able to match to objects on the background window. So it seems that I'm failing to match to the window by title. I've also tried just using selectWindow / selectPopup with no parameters, but there's no change.
It is important to note that the window is launched through the click of a button, which also creates the name of the window based on its id which isn't available to Selenium, hence we need to launch based on title, not name, and I'm unable to use openWindow or similar since the url etc are generated by the underlying system. I just need a consistent way to select the popup.
Does anyone know how I can resolve this?
The issue you are facing is that there is a bug in selenium IDE where it can only recognize windows that IT opened. You are unable to select the new window with "selectWindow" because Selenium IDE did not "Open" the window. It "clicked" on the link, and the webpage "opened" the window.
The workaround is to use storeAttribute on the hyperlink element pointed #href to extract the url from the link and store it as a variable. Then use openWindow. So instead of:
<tr>
<td>click</td>
<td>//table[#id='dtgList']/tbody/tr[1]/td/a/u</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>10000</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>Profile</td>
<td></td>
</tr>
Use this tactic:
<tr>
<td>storeAttribute</td>
<td>//table[#id='dtgList']/tbody/tr[1]/td/a#href</td>
<td>Profile</td>
</tr>
<tr>
<td>echo</td>
<td>${Profile}</td>
<td></td>
</tr>
<tr>
<td>openWindow</td>
<td>${Profile}</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>10000</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>Profile</td>
<td></td>
</tr>
Hope that helps.
Sometime giving an explicit window locator type helps. Specify that you are giving a window title by prefixing your title with a title= to the selectWindow or selectPopup command as below.
selectWindow title=my window title
This may work for you
click link=activate
waitForPageToLoad
selectWindow Third party activation site
or try this
[info] Executing: |storeEval | this.browserbot.findElement('link=Pastanet').href | Link_PastaNet |
[info] Executing: |openWindow | ${Link_PastaNet} | MyWindows |
no solution, but I have a similar issue
it seems to me, that there is a problem with background windows. if the window you want to select is behind another window, you cannot select it - it only works if the window is already in front
user2989297 and Samit Badle are correct, but I found their answers very vague and confusing until I ran across another post that helped me put it all together.
The trick is to Assign your own name to the window you want to select, during the openWindow call. That is the purpose of the stored variable, though it isn't clear in the example above. I would suggest the following may be more easily understood.
<tr>
<td>storeAttribute</td>
<td>//table[#id='dtgList']/tbody/tr[1]/td/a#href</td>
<td>varNewWindowName</td>
</tr>
<tr>
<td>echo</td>
<td>${varNewWindowName}</td>
<td></td>
</tr>
<tr>
<td>openWindow</td>
<td>${varNewWindowName}</td>
<td>Profile</td> - this is where we assign it a new name, 'Profile'
</tr>
<tr>
<td>pause</td>
<td>10000</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>Profile</td> - now we can select it, using the new name
<td></td>
</tr>
If you're working in the Selenium IDE, the equivalent commands are;
Command: storeAttribute
Target: //table[#id='dtgList']/tbody/tr[1]/td/a#href
Value: varNewWindow
Command: echo - I've read that the echo command is optional, but I used it
Target: ${varNewWindow}
Value:
Command: openWindow
Target: ${varNewWindow}
Value: Profile - again, this is where we assign the new name
Command: Pause
Target: 10000
Value:
Command: selectWindow
Target: Profile - and then use the new name
Value:
I can see this issue was popular in Selenium IDE ...for now, i have an easy way to solve this issue . Why you don't create a new Test Case ? it will select New Window or Popup as you want
The best solution is to leave empty the target & put the title as a value.
Command: selectPopUp
Target:
Value: Your popUp title