Selenium IDE: How to tell if a user clicked Cancel on a scripted Prompt? - selenium-ide

This seems like a very basic question, but just can't figure it out...
I am using a prompt to collect input parameters from my users during script execution with the following line:
|storeEval|prompt("How many test users would you like to create?")|dataHowMany|
and this works fine to collect the number. But...
Question: How do I tell if the user clicked the Cancel button (regardless of entering data or not) instead of the OK button? If they click Cancel I want to be able to gotoif and end the execution.
I have tried playing with assertConfirmation and assertPrompt, but they do not seem to be the commands I am looking for.

I am not 100% sure that I've got the idea of your question. But if I am right here is the answer:
You need Selenium IDE flow control extension to do it.
storeEval | prompt("How many test users would you like to create?") | dataHowMany
gotoIf | ${dataHowMany}==null | ENDOFTEST
.....
.....#Your test here
.....
label | ENDOFTEST

Related

get the current view which is displayed to user and verify

I am testing my eclipse rcp app GUI using a tool called RCPTT.
In rcptt, i want to check that a specific editor is opened or not.
right now i am using
get-view "Console" | get-table | is-disabled | verify-false
but this is wrong way to do verification.
using this code, if the console is not opened, than it click on console and do verification.
It passed all time.
So, is there any way to
- first get the current view(which view is displaying currently to user.)
- then verify this view.
Thanks
You can not solve it within ECL, there's no support for this.
However you can solve it with Java code. It's not easy, could be a few hours of work.
1) Write a Java method that detects the name of the active View and returns it as a String
2) Make sure it's part of your application as a static class's static method
3) Invoke it from your ECL script with the invoke-static command
4) Compare the returned value in ECL script to what you've expected
Check methods parseComposites(), viewOrEditorIsFocused() and checkNextComposite() from this tutorial:
https://openchrom.wordpress.com/2011/08/12/capture-a-snapshot-of-the-active-vieweditor-in-a-rcp-application/
You do not need all the code from it and you need some editing too.
If you make an error/typo at points 2) or 3), then RCPTT-runner will simply throw an Exception without further explanation; be careful there.

Selenium: selectWindow is not working outside of the testcase

The test:
Testcase 1 has one selenese: openWindow | ${url} | ${name}
Testcase 2 has one selense: selectWindow | ${name} |
And it returns an error: [error] Could not find window with title ${name}.
If the two selenses are in one testcase, the test passes.
I was looking in the docs: http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.DefaultSelenium.SelectWindow.html , but didn't find any related restrictions about the method - you can select windows only opened in the same testcase. Is that a known limitation or am I doing something wrong? Is there a workaround?
Yes that is a known limitation. There may be away around it but I am unaware of it(maybe you could try using a different tab for each test). Your best bet is to use the webdrivers. I have migrated from using the selenium firefox extension to C#, there is no comparison in the benefits of using this.
There is this open bug: https://code.google.com/p/selenium/issues/detail?id=1136
which may be causing what you're seeing. Try selectWindow by another method (instead of the name, look by title)

Working with layout object attributes and variables in FileMaker

This is the first time I'm encountering GetLayoutObjectAttribute and I am having serious issues with it. My variable $web won't set. I think it's because PD_WebV isn't the right object name to refer to, but I don't know how to find the right object name. I can't find the objects name when I hit Edit Layout, so does anyone know how to find an layout objects name?
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
If[$Web="done"]
#execute if statements
After Edit:
After some troubleshooting, I found out that PD_WebV is the right object name to refer and it's refered to correctly, so my new question is why doesn't the script go to the line If[$Web="done"] and how could I fix it? Ss my If statement not evaluating something it should be? Is my $web variable never set to done or is the issue something completely different? Would the problem possibly have to do with my WebDirect sharing settings? Any guidance would help. Thanks.
After, After Edit:
So now that my application is getting past Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")], the variable $web only equals <HTML></HTML>. Does anyone know a way, without using javascript, to test the inside of the html tags?
Also, I printed the bounds of the webViewer PD_WebV that I can't locate on the layout but am referring to in the script. The bounds that are printed are different each time I run the script. Is the usual or unusual? My source is also about:blank so it doesn't look like I'm sourcing from a URL
Is my $web variable never set to done or is the issue something
completely different?
If you're doing:
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
then the only time
$Web="done"
will return true is when the web page loaded into your web viewer contains exactly the string "done" (in practical terms, that's never).
I have already suggested in a comment that you test for:
PatternCount ( $webpage ; "</html>" )
This is assuming you want the subsequent steps to execute only after the page has finished loading. The entire script would look something like this:
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
Exit Loop If [ PatternCount ( $webpage ; "</html>" ) ]
End Loop
# execute statements
You might also want to add a counter to the loop and exit the script after n trials.
Ah, I reread your question.
To set the object name for your webviewer so that the GetLayoutObjectAttribute function works you need to set it in the Name field in the inspector when you have the webviewer selected.
e.g.:
After that your variable should populate.
Be aware
What it will populate with will be all of the html from the browser, i.e. not a boolean true/false liek your conditional suggests.
I'm not sure exactly what you're trying to accomplish, but to be able to determine a result from your web viewer you'll need to either parse the HTML to see if it's content contains what you're looking for or within the code you're setting the webviewer with, fire a javascript function that calls back to the FileMaker file using a FileMaker url.

NirCMD run multiple commands from a context menu

I would like to run a few NirCmds when running an application such that it will change the primary display to the extended monitor, run the app and then switch back when finished. Ideally I would like to create this as a context menu option. Since this is using multiple commands I thought of using the script functionality from nircmd such as:
script "$folder.desktop/testscript.ncl"
with the script containing the lines I needed:
setprimarydisplay(2)
exec max "???.exe"
waitprocess ???.exe setprimarydisplay(1)
However I am not sure how to pass the process name from the context menu into the script or if this is even possible. Does anyone know how to do this or am I approaching this the wrong way?
I have the process location from the context menu as %1, so the issue is really just passing this into the script. Something like:
script "$folder.desktop/testscript.ncl" -%1

How do I write the selenium IDE test case for CAPTCHA images?

I am working on Selenium IDE for writing the test cases for a registration form. The registration form has a CAPTCHA image so I am not able to proceed with the automation, What could be the best solution to go ahead with? If I can provide a break point and let the user type it manually, then what is the command for carrying out that action? What are the best possible solutions with the complete commands>?
Fun Fact: When you can't automate it, the CAPTCHA is doing it's job. :>
Solution # 1
Temp remove the CAPTCHA for the testing
Solution # 2 (As you mention to provide a break point to insert captcha manualy)
1. Try prompt a text box for user to key in the captcha, and store in variable
example:
storeEval | prompt("Enter Captcha:") | varName
Then type the varName text in to your captcha text box
example
type | id=CaptchaText | ${varName}
Hope this helps.
Another method is by just add 3 pause saying something like " Write Captcha Manually" with 9 second each. see example below:
Command : Pause
Target: 9999
Value: "Write Captcha Manually"
This will give you time to type the captcha.