select Window doesn't close - selenium-ide

I have a window, it open (programmatically in the code) a paypal window, the title is: "Se connecter pour terminer le paiement - PayPal"
I want to close it first, then close our current window, i use the code:
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>css=td > h1</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>Se connecter pour terminer le paiement - PayPal</td>
<td>Se connecter pour terminer le paiement - PayPal</td>
</tr>
<tr>
<td>close</td>
<td></td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>null</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=connexion</td>
<td></td>
</tr>
it it says it cannot find the window with title "Se connecter pour terminer le paiement - PayPal", I see it in my html header title though
What can i do?

Related

Selenium IDE - Go back one page, if an error is returned

I was given a task to retrieve a rather large number of PDF files from the clunky front end system of a former contractor. One must enter the file name, search, revalidate the file five or six times, then download the file.
I have written a script to do this in a loop, and so far, it's gotten the job done. However, if the file isn't found, it spits you to a new page, where it displays an error. You must then go back one page, and resume.
My issue is that I can't quite find a way to tell Selenium IDE "if you see this error, go back one page and resume" or "if the page changes, go back one page and resume."
Is it possible for Selenium IDE to follow an If command like this?
I have downloaded and installed all of the relevant plugins.
My script is as follows:
<!--Begin loop-->
<tr>
<td>loadTestData</td>
<td>file://C:\[[the file path]]\test_data.xml</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>!testdata.EOF()</td>
<td></td>
</tr>
<tr>
<td>nextTestData</td>
<td></td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>bizcase_filename=${bizcase_filename}</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=srch</td>
<td>${bizcase_filename}</td>
</tr>
<!--Begin revalidation (5 times)-->
<tr>
<td>click</td>
<td>css=input.button</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=td > img</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>id=action</td>
<td>label=Revalidate</td>
</tr>
<tr>
<td>click</td>
<td>//input[#value='Run']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pbStop</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=td > img</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//input[#value='Run']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pbStop</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=td > img</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//input[#value='Run']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pbStop</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=td > img</td>
<td></td>
</tr>
<!--End revalidation, retrieve file-->
<tr>
<td>click</td>
<td>//td[5]/a</td>
<td></td>
</tr>
<!--End loop-->
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
Test_data.xml, where I store all the file names, looks like this:
<testdata>
<test bizcase_filename="filename 1" />
<test bizcase_filename="filename 2" />
<test bizcase_filename="filename 3" />
</testdata>
You can use build in function called storeElementPresent
For example:
storeElementPresent id="error" x
And now, object "error" is stored in variable x.
Then you can call it with gotoIf function available from goto_sel_ide extension.
Example:
gotoIf ${x}==true errorVisible
gotoIf ${x}==false errorNotVisible
label errorVisible
goto tryAgain //tryAgain is a label set in right place
label errorNotVisible
goto Continue
label Continue
I hope you get the point. You can also use "if" statement by javascript.
Example (not related to your code):
storeElementPresent id=gbqfbb x /
click javascript{if(storedVars['x'] == true){this.browserbot.findElement('id=gbqfbb').click();}}
Hope it helps!

how to type text in a field it is blank in selenium ide

I need to type text in a field only if it is blank,if it has value proceed to next.
How to verify if field(id=Status) is empty then type a text"itemtoExpire" else continue with click id=submit button
Any suggestions using verify, gotoif, labels.
I am using selenium IDE
You may need to use the runScript command in Selenium IDE.
<tr>
<td>runScript</td>
<td>var val = document.getElementById('Status').value; if (val == '') { document.getElementById('Status').value = "itemtoExpire"; }</td>
<td></td>
</tr>
First you would require Selenium Flow Control to test conditions then use
type | id=input_id_or_selector | value_to_time
After the downloading of the plugin Selenium IDE: Flow Control try these commands in Selenium IDE that i think will work for your scenario.
<tr>
<td>storeText</td>
<td>id=Status</td>
<td>text</td>
</tr>
<tr>
<td>gotoIf</td>
<td>'${text}'!=''</td>
<td>submit</td>
</tr>
<tr>
<td>type</td>
<td>id=Status</td>
<td>itemtoExpire</td>
</tr>
<tr>
<td>goto</td>
<td>end</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>submit</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=submit</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>end</td>
<td></td>
</tr>

Selenium IDE/Flow Control - gotoif condition

I'm new to gotoif condition in SeleniumIDE.
Trying to use it to test this scenario in the same test:
If page displays "test" icon, then click Launch and skip next step.
If page doesn't display "test" icon, then proceed to next step.
If You allways have pictire (but diffrent) in this place, You can get Xpath and get scr atribue of this picture:
<tr>
<td>storeAttribute</td>
<td>//body/div/img#src</td>
<td>urladress</td>
</tr>
<tr>
<td>gotoIf</td>
<td>'${urladress}'!= 'http://mypage.com/img/test.ico'</td>
<td>marker1</td>
</tr>
<tr>
<td>echo</td>
<td>Here commands for this picture</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>marker1</td>
<td></td>
</tr>
<tr>
<td>gotoIf</td>
<td>'${urladress}'== 'http://mypage.com/img/test.ico'</td>
<td>marker2</td>
</tr>
<tr>
<td>echo</td>
<td>Here commands without this picture</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>marker2</td>
<td></td>
</tr>
If it do not work you can use javascript function:
<tr>
<td>storeBodyText</td>
<td>body</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>javascript{storedVars['body'].search('test.ico')}</td>
<td>result</td>
</tr>
<tr>
<td>gotoIf</td>
<td>${result}==-1</td>
<td>marker1</td>
</tr>
<tr>
<td>echo</td>
<td>Here commands for this picture</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>marker1</td>
<td></td>
</tr>
<tr>
<td>gotoIf</td>
<td>${result}!=-1</td>
<td>marker2</td>
</tr>
<tr>
<td>echo</td>
<td>Here commands without this picture</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>marker2</td>
<td></td>
</tr>

how to automate autocomplete tags in selenium ide?

<tr>
<td>clickAt</td>
<td>css=ul.token-input-list-facebook</td>
<td></td>
</tr>
<tr>
<td>setCursorPosition</td>
<td>id=token-input-SongTags</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=token-input-SongTags</td>
<td>n</td>
</tr>
<tr>
<td>setCursorPosition</td>
<td>id=token-input-SongTags</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=token-input-SongTags</td>
<td></td>
</tr>
I tried out the above steps to automate autocomplete tags, but this is not working,
Can anyone help me out here?
<tr>
<td>clickAt</td>
<td>css=(first click)</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=(second click)</td>
<td>${tagname}</td>
</tr>
<tr>
<td>typeKeys</td>
<td>id=(second click)</td>
<td>${tagname}</td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>focus</td>
<td>id=(second click)</td>
<td></td>
</tr>
<tr>
<td>keyDown</td>
<td>id=(second click)</td>
<td>\40</td>
</tr>
<tr>
<td>keyDown</td>
<td>id=(second click)</td>
<td>\40</td>
</tr>
<tr>
<td>keyDown</td>
<td>id=(second click)</td>
<td>\13</td>
</tr>

How do I include a stored value in a css path with Selenium IDE?

For example:
<tr>
<td>storeEval</td>
<td>a_string</td>
<td>my_var</td>
</tr>
<tr>
<td>verifyElementPresent</td>
<td>css=#some_id[some_value='<my_var>']</td>
<td></td>
</tr>
css=#some_id[some_value='${my_var}']