Selenium IDE: how to popup a dialog and wait for user to click OK - selenium

Just wonder if we could do something like below when running a selenium scenario, which needs user's interaction to continue. Like wait for him to upload some images..
Till the step, the selenium popup a dialog saying: please complete something, then click the OK button to continue.
When user finishing the operation on the webpage, then click "OK", then the scenario's transaction is moving forward. Otherwise, stop on that step.
For the first bullet, I was thinking of below command:
Command:
waitForConfirmation
Target:
javascript{confirm("Please upload the images, then click OK to continue")}
Thanks in advance!

In selenium ide use storeeval command, different type of boxes
COMMAND | TARGET | VALUE
----------------------------------------------------------------------------
storeeval | alert("This is alert box") |
storeeval | prompt("This is prompt box. Please enter the value") | text
storeeval | confirm("this is cofirm box") |
Type | locator of text box | ${text}

1.) we can create a message box and can assign the value given in the message box to a text box.
Command:StoreEval
Target:prompt{("Enter the Message")}
Value:Text
here a pop up message box will pop up and you can enter some text into it and it will store in the variable "Text" the value in the Text can be assigned to a text box or other
Command:type
Target:id=id of the text box
value:${Text}
2.)same as above we can create an alert box
Command:StoreEval
Target:alert{("Enter the Message")}
Try these things
Thank you.

Related

Selenium IDE Flow Control (gotoif) - "Error: Specified label "labelName" is not found"

I am creating a test and before the test tests something, the language of the website has to be changed. After the gotoif which checks if the language isEnglish I want to jump to the label "labelChangeLanguage", but I always get the excpetion that it couldn't be found. But well, it's there.
Here the screenshot of the failing selenium test:
What am I doing wrong?
You have two gotoif conditional statements where you only need one. Just use the first one and then a gotoLabel for the next line like this:
gotoIf | '${isEnglish}'== 'true' | changeLanguage
goto | done
label | labelChangeLanguage
goto | done
label | done
The way it works, it will evaluage ${isEnglish}. If that's true it will jump to the label changeLanguage, if not, it immediately goes to the next line, which will jump to your done label. Note that I changed the label to remove the word label in the name for readability.

Alert is not showing during manual but alert is showing in automation

I need to clear the textbox and enter value .After that i am moving to next step.This scenario is working fine in manual but not in automation.After enter the value and trying to move next step but alert is showing with following message
"Textbox field should not be empty".But already value is in textbox which i entered.Anyone please give me suggestion.
After enter the value in the textbox just click the same textbox then alert will not show in this type of scenario

Reload page if stored Text is a certain value using Selenium IDE?

I am using storeText | css=strong | k
to pull a value from my webpage.
If the value put in 'k' is "reload" I want to refresh the page.
Which function in selenium IDE can accomplish this?
Thank you!
First check what the value is in k , then you can use
refresh
or probably
refreshAndWait
for page refresh.
Source : http://seleniummaster.com/sitecontent/index.php/introduction-to-selenium-automation/selenium-ide/114-selenium-ide-complete-list-of-commands

Clicking a "add comment" button

When I am recording my script my scrpit is failing when it is coming to the part of clicking the "add comment" icon. The error I am getting is that the element is not found. The html script is :
a id="cmt_place" class="btn add_comment" onclick="javascript:SNI.Community.Toolbox.TopNavCheckandShow()">
So I am confused which command I should use and what the target and value should be so that when the test runs it should be able to automatically click the add comment icon.
New Test Case
open /registration/login.esi
type id=up-ur-email
type id=up-ur-password
click css=#up-ur-widget-login > #up-ur-widget-nav-item-off > a > em
open /home/home.esi
click link=TEST_upload
click id=Add Comment
click id=commenttext
type id=commenttext test123
click css=#post-comment-omnt > em
clickAndWait link=Log Out
open /registration/login.esi
type id=up-ur-email
type id=up-ur-password
click css=#up-ur-widget-login > #up-ur-widget-nav-item-off > a > em
open /home/home.esi
click link=TEST_upload
Pause 30000
click id=Add Comment
click id=commenttext
type id=commenttext test123
click css=#post-comment-omnt > em
clickAndWait link=Log Out
pause command will pause 3 second before click the Add comment button.
Try this.
Thank you.
use Xpath of comment box in target field and use pause & setCursorPosition command
pause to wait for some time and setCursorPosition command to point comment box
open /registration/login.esi
type id=up-ur-email
type id=up-ur-password
click css=#up-ur-widget-login > #up-ur-widget-nav-item-off > a > em
open /home/home.esi
click link=TEST_upload
click id=Add Comment(use Xpath of comment box instead of this)
pause 2000
setCursorPosition id=commenttext
click id=commenttext
type id=commenttext test123
click css=#post-comment-omnt > em
clickAndWait link=Log Out

Autohotkey Win XP automating small task

I have a small task I would like to automate with Autohotkey and it looks like it is more or less directly transferable to autohotkey syntax:
1. Ctrl+v
2. Alt+tab
3. Click certain link in a window (no combo-key for this but it's always in the same place)
4. Enter (carriage return)
5. Alt+s
6. Ctrl+v
7. Enter
Now it would be nice to map this combo to something else e.g. Windows Key+Space.
What I have got so far is:
0. SetWinDelay 100 (using a connection to an remote computer)
0. SetKeyDelay 0
1. Send, ^c
1. ClipWait, 0.1
2. Send, {Alt down}{tab}
2. Send, {Alt up}
3. ?????
4. Send, {enter}
5. Send, !s
6. Send, ^v
7. Send, {enter}
Is this approximately right? Anyone up for helping me fix it or filling in the holes, so to speak :)
Another alternative to step 3, 4 and 6 would be to simply loop though the contents of the clipboard (a number string) and sending each letter of the string to keypresses? Maybe this would be the easier way
If you want to "click" on a certain position, to open a menu, you can first right click on your AutoHotKey icon and open the "window spy". This window spy will show you the mouse position. Yo can use the mouse positions to perform your actions in the active application.
Example:
SoundBeep 1000, 300 ; Wake up user
SplashTextOn, 200, 100, Script Preparations, Please Click on the person icon link. ; Show new Instructions text
WinMove, Script Preparations,, (A_ScreenWidth/2)+150, (A_ScreenHeight/2)+200 ; Move the window with the name "Script Preparations" Down and Right on the main screen
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xposE ,yposE ; Store the position where the mouse was clicked (Employee)
MouseClick, left, %xposE% ,%yposE%, 2 ; Perform a double mouse click on the captured mouse location
SplashTextOff ; Remove Text box
In this case, I first ask the user to manually click on the right location. This is only required when the position to click changes WITHIN the active window (variable tiles within the active window). Once you have the position stored, you can re-use it all throughout your script.
b.t.w. instead of using Alt+Tab, I suggest using this:
settitlematchmode, 1 ; Set search in title to start with....
settitlematchmode, Fast ; Slow is not required here. Slow is only required when hidden text needs to be found.
SwitchWindow("Microsoft Excel - 1 QRM Upload and Change Template") ; Activate the
window with the title: Microsoft Excel - 1 QRM Upload and Change Template
You could even use someting like this:
SetTitleMatchMode, 2 ; Ensure that the Title Match mode is set to 2: Find anywhere in the title
SetTitleMatchMode, Fast ; Ensure that the Title Match mode is set to FAST
winactivate, %WindowName% ; Activate the window with the title stored in the variable WindowName
WinWaitActive, %WindowName%, , 5 ; Wait up to five seconds for the screen
if ErrorLevel ; Execute this when the window is not activated within 5 seconds
{ ; Start-If Wait failed
SoundBeep 1000 , 1000 ; Warn the user
MsgBox,4097,Time Out, Script timed out while waiting for %WindowName%.`n`rYou Must manually activate %WindowName% and then continue the script by pressing OK. ; Message to user
IfMsgBox, Cancel ; Do when the user clicked on Cancel
{ ; Start-If User clicked Cancel
ExitApp ; Exit this program when the user clicked on Cancel
} ; End-If User clicked Cancel
WinWaitActive, %WindowName%, , 5 ; Try to activate the window AGAIN
if ErrorLevel ; If window can't be found
{ ; Start-If window can't be found
MsgBox,4096,Exit, %WindowName% still NOT Active. ; Warn user
ExitApp ; Exit this program when the expected window is still not found
} ; End-If window can't be found
} ; End-If Wait failed
Regards,
Robert Ilbrink