Selenium ide change values at runtime - selenium

I want to change the value of global param inside while loop.
For some reason the value isn't changing although I'm inserting a new value.
<tr>
<td>store</td>
<td>1</td>
<td>CallTime</td>
</tr>
<tr>
<td>while</td>
<td>${OnCall}==true</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>callStateLabel_16#text</td>
<td>ElapsedTime</td>
</tr>
<tr>
<td>echo</td>
<td>${ElapsedTime}</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>storedVars['CallTime']=${ElapsedTime}</td>
<td>CallTime</td>
</tr>
<tr>
<td>echo</td>
<td>${CallTime}</td>
<td></td>
</tr>
The last echo gives 1 while the elapsed time is 00:35. How should it be done?

instead of "store" you should use "storeEval", and leave field "value" empty
try
<tr>
<td>storeEval</td>
<td>storedVars['CallTime']=${ElapsedTime}</td>
<td></td>
</tr>

Related

Selenium goBack and wait

I have this selenium test (a part of it).
<tbody>
<tr>
<td>open</td>
<td></td>
<td>localhost:8091</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Rest objects</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[3]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>xpath=(//div[not(div)][1])</td>
<td>ID: 2</td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
</tbody>.
I use Selenium IDE in Firefox. When I run it slowly (toggle speed), it works well. However, when I try to run it faster, I get error at the step <td>clickAndWait</td> after <td>goBack</td>. The log says,
Element xpath=(//a[contains(text(),'Show')])[5] not found.
My questions, how to go back and wait until the page is loaded before I perform other actions.
You have to use waitForPageToLoad command adter click on element till the page loaded and then perform other actions
Use Below code
<tr>
<td>click</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>10000</td>
<td></td>
</tr>
Thanks (#Trimantra Software Solution).
waitForPageToLoad this is what I needed.
From documentation:
waitForPageToLoad(timeout)
Arguments:
timeout - a timeout in milliseconds, after which this command will return with an error
Waits for a new page to load.
This is my solution, I used waitForPageToLoad after goBack.
<tbody>
<tr>
<td>open</td>
<td></td>
<td>localhost:8091</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Rest objects</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[3]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>xpath=(//div[not(div)][1])</td>
<td>ID: 2</td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>800</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
</tbody>
I see a goBackAndWait() variant of this command. That might work for you.
Typically I'd advise using a waitFor to ensure the page is back to where you want. Simplest that may work is waitForTitle if possible.
waitForElementPresent & waitForText also good ones to look at.

How can i verify text present in Selenium IDE?

I have a form to check code Order in which I put "phone number" to search.
In a result list, I use verifyTextPresent to verify the value, but it fails.
Here is my link https://ventomarme55.bizwebvietnam.net/apps/kiem-tra-don-hang
and here my code:
<tr>
<td>open</td>
<td>https://ventomarme55.bizwebvietnam.net/apps/kiem-tra-don-hang</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>name=CheckType</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=PhoneNumber</td>
<td>0987610597</td>
</tr>
<tr>
<td>click</td>
<td>//button[#class='btn pull-right']</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Số điện thoại: 0987610597</td>
<td></td>
</tr>
Use Value for input
<tr>
<td>open</td>
<td>/apps/kiem-tra-don-hang</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=PhoneNumber</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=PhoneNumber</td>
<td>4141414</td>
</tr>
<tr>
<td>waitForValue</td>
<td>id=PhoneNumber</td>
<td>4141414</td>
</tr>
<tr>
<td>verifyValue</td>
<td>id=PhoneNumber</td>
<td>4141414</td>
</tr>

Selenium IDE wont click on dynamic id

I'm having trouble getting a link clicked on Selenium IDE.
The id is picked from the itteration in a while loop but i can't get the ID echo'ed in somehow.
This is my code:
<tr>
<td>open</td>
<td>/list</td>
<td></td>
</tr>
<tr>
<td>storeAllLinks</td>
<td>linkArray</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>0</td>
<td>index</td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td><!-- should be array length but that wont word eighter, problem for later -->
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=${index}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
Anny clues on whats going wrong would be great help.
Thank you in advance!
You can locate link by its text. Use of Xpath and link text might help you.
Or please share part of HTML.

How to manipulate the 'value' in selenium IDE?

The Scenario is,
I recorded the task, which is,
Login, edit a field and save it with different name(but the original field remains),logout.
Here i need to manipulate the 'name' field, so i can get 100 or more copies of it, with unique names.
Is it possible in Selenium IDE?, if not , is there any open source tool available to do the same?
</thead><tbody>
<tr>
<td>open</td>
<td>/SurveyHome.aspx</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_gvSurvey_ctl02</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=ctl00_ContentPlaceHolder1_txtsurname</td>
<td>Survey 1</td> // This is the name of the survey.
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_btncopysurok</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=ctl00_ContentPlaceHolder1_btncopyok</td>
<td></td>
</tr>
</tbody></table>
How to use the while loop in this code, i tried using but, the selenium ide is not recognising it.Can you plz help me with this..
You can use while loop for your purpose
<tr>
<td>getEval</td>
<td>index = 1;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>survey ${value}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
in the name text box field you give the value has survey ${value},
now you can create any number of form with unique name by
using this while loop put your form inside this while loop.
Try it
Thank you.
<tr>
<td>open</td>
<td>/SurveyHome.aspx</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index = 1;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 100;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>survey ${value}</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_gvSurvey_ctl02</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=ctl00_ContentPlaceHolder1_txtsurname</td>
<td>survey ${value}</td>
</tr>
<tr>
<td>click</td>
<td>id=ctl00_ContentPlaceHolder1_btncopyok</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
try it.
thank you

Cannot execute a Selenium IDE test case for a Pop Window

Hi can any one please help me with this script please.
I cannot run a test case for pop window with selenium IDE.
here is the following script i am using to run the test case.
<tr>
<td>open</td>
<td>/car-insurance</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Car Insurance | Netpig Insurance</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//img[#alt='Get an insurance quote']</td>
<td></td>
</tr>
<tr>
<td>selectPopUpAndWait</td>
<td>GetaCarInsurancequote</td>
<td>30000</td>
</tr>
<tr>
<td>selectWindow</td>
<td>null</td>
<td></td>
</tr>
<tr>
<td>assertTitle</td>
<td>Car Insurance | Netpig Insurance</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>form1:txt_4_3_0_Policy_CoverDate</td>
<td>26</td>
</tr>
<tr>
<td>type</td>
<td>form1:txt_4_4_0_Policy_CoverDate</td>
<td>05</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtRegLookup</td>
<td>VN05XVO</td>
</tr>
<tr>
<td>click</td>
<td>form1:imgGetVehicle</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVehicleYearOfManufacture</td>
<td>label=2006</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVehicleModified</td>
<td>label=Select</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVehicleModified</td>
<td>label=No</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtPurchaseDateDay</td>
<td>10</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtPurchaseDateMonth</td>
<td>02</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtPurchaseDateYear</td>
<td>2009</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtVehicleEstimatedValue</td>
<td>2001</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVehicleNightLocation</td>
<td>label=Car Park</td>
</tr>
<tr>
<td>type</td>
<td>form1:txtOvernightPostCode</td>
<td>wr51dh</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVehicleCoverType</td>
<td>label=Third Party Only</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboVolExcess</td>
<td>label=£300</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboNCBYears</td>
<td>label=9</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboNCBProtected</td>
<td>label=No</td>
</tr>
<tr>
<td>select</td>
<td>form1:cboNCBType</td>
<td>label=Motorcycle</td>
</tr>
if any one have some solution please email mail me on dhanunjayakumar#gmial.com
<tr>
<td>selectWindow</td>
<td>null</td>
<td></td>
</tr>
This piece looks problematic it should be like
<tr>
<td>selectWindow</td>
<td>name=NameOfPopupWindow</td>
<td></td>
</tr>
[error] Permission denied for http://www.netpig.co.uk to call method Location.toString on http://quotes.netpig.co.uk
Its Same Origin Policy Issue
Your popup window on http://www.netpig.co.uk is not allowed by browser to modify DOM on http://quotes.netpig.co.uk because its different domain.