Is it possible to use an "if" command with a "verify text" command in Selenium IDE? - selenium-ide

After clicking a button I want to verify if certain text has showed up. If so, run some command. If not, then test for something else. Is it possible to do this by writing the result of verify text to a variable and then testing that in an if command?

Figured it out.
Command Target Value
---------- -------------------- -----------
store text id=targetText someVar
if ${someVar} == "blah"
// do something
end

Related

Running "preamble" code in MATLAB

Is there any way to make MATLAB run a certain chunk of code every time you try to run a script? For instance, I would like MATLAB to run
sprintf('Here we go...')
as soon as I hit the Run button and then move on to execute my script, so if my script were
i = 1;
i = i * i;
display(i)
I would get
ans =
Here we go...
i =
1
P.S. I would appreciate it if the people with higher reputation please corrected the title of my question for it to better reflect the content.
as soon as I hit the Run button
I am assuming you are talking about the run button in the editor. In R2012a there was a feature called "Run Configuration". A run configuration was linked to a specific script and included code to be executed prior to the script being run. There does not appear to be a global setting to be used on all function. This feature appears to have been silently removed in R2012b.
In R2013b you can chose to run a different script. Presumably you could hack the editor to get the current file and use the custom run script to run your preamble and then the current editor file. This seems like a lot of work for not much return ...
You could create a file called myrun.m
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jEditor = desktop.getGroupContainer('Editor').getTopLevelAncestor;
title = jEditor.getTitle;
currentFilename = char(title.replaceFirst('Editor - ',''));
fprintf('Here we go...');
run(currentFilename);
and this in the editor under run Run: type code to run type myrun. One you do this once it will remember your preferences and you can then run you code via myrun with F5. It will remember your preferences across restarts.
The way to do this would be to have a preamble.m and doThis.m. In preamble.m you'd have this:
sprintf('Here we go...')
and then in doThis.m, you'd have
preamble
i = 1;
i = i * i;
display(i)
The only trick to making this work is to have them both on the path, or in the same directory.
Not sure if I got what you want, but you can divide Your m file into Code Sections. For example:
%% Section 1
sprintf('Here we go...')
%% Section 2
i = 1;
i = i * i;
display(i)
The %% is a section break. Place your cursor in the relevant section, and on the Editor tab, in the Run section, click Run Section. (or press Ctrl+Enter)
see here for more info.
If you only want this for one (or a few scripts) either add the command in the script, or make a wrapper function/shortcut.
If you want this for many scripts without input, you can create a generic wrapper:
Suppose you want to run things like myFun(a,b,c) then create a wrapper that you can call like this:
myWrapper('myFun(a,b,c)')
Then you can first call your display command and then use eval on the input of myWrapper. Note that this becomes cumbersome if your function call is multiline or contains quotes.
If these solutions can't help, you probably need to ask yourself why you are trying to do this and whether there is a better solution for the underlying problem.

Appcmd command not working

appcmd set config /section:applicationPools /[name='xxx - yyy'].processModel.idleTimeout:0.00:00:00
When I run this command, instead of receiving a validation message or an error message, the command goes "idle".
It actually just display the caret and I can write text, or wathever... until I CTRL+Break the command.
I tried waiting for 10 minutes but nothing else ever happens.
It's really weird, the command seems correct :S
Do you know what I possibly could be doing wrong?
Apparently when there is a space in the application pool's name, you have to put the "modification parameters" in quote.
So the command should actually be like this:
appcmd set config /section:applicationPools "/[name='xxx - yyy'].processModel.idleTimeout:0.00:00:00"
It really gets me to wonder why the simple quotes aren't useful enough.

How can I declare a variable within a hotstring in AutoHotKey?

I'm trying to create a script that will take a name and add it to a pre-written block of text.
Essentially, I want to write "emailDave" and have the name Dave inserted into a string of text that is then sent. I'm just not sure how to modify a hotstring this way.
I'm currently using a method that asks for the name using an InputBox and inserts the name into the text. That works just fine on the Desktop, but I'm using Windows 8 and for some horrible reason, InputBox won't show up in-App (i.e. outside of Desktop mode).
I know there's got to be a way to use the text I input "email vs emailDave" to affect the variable instead of taking me on this goose chase with InputBox.
That said, if anyone knows a workaround for displaying InputBox in Windows 8 apps (particularly Mail), that would be more than helpful.
Current script that runs fine on Desktop but won't work in-App:
::email::
InputBox, thename, Enter the name, What is the name
SendInput Hi %thename%,{enter}{enter}Sample text.{enter}{enter}Thanks,{enter}Zach
Return
Is there any way to make something like this work?
::email{%thename%}::
SendInput Hi %thename%,{enter}{enter}Sample text.{enter}{enter}Thanks,{enter}Zach
Return
How about his:
:?*:email::
Input, thename, v,{Enter}{Space}
If (thename = "")
{
SendInput, {Bs}email `
Return
}
StringLen,MyLen, thename
MyLen++
SendInput {BackSpace %MyLen%}Hi +%thename%,{Enter 2}Sample text.{Enter 2}Thanks,{Enter}Zach
Return
By adding a + in front of the name string the first letter will be capitalized.
Input: "emailrobert{Enter}" or "emailRobert{Enter}" both give:
Hi Robert,
Sample text.
Thanks,
Zach
and email{Space} will give email{Space}.
If you really would like to avoid using an InputBox, I have a more complicated solution for you. You can use a library called RegEx Powered Dynamic HotStrings.
Save the file at that link into your lib folder inside the folder containing AutoHotkey.exe (create if necessary).
In this example, you type emailJohn followed by a Space.
#Include lib\DynamicHotstrings.ahk
hotstrings("email(\w+)\s", "email")
Return
email:
SendInput, Hi %$1%,{Enter 2}Sample text.{Enter 2}Thanks,{Enter}Zach
return
::email::
inputbox, name
msgbox, %name%
return
take "dave" out of the hotstring
After you test, replace the msgbox, %name% with whatever send line you want.

CMD Batch File With Muliple Inputs

I am trying to automate a command that prompts the users for their pin, the command in question;
tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate
at this point you press enter, the next thing you see is
Enter Pin:
You enter the pin and press enter, then you get asked to confirm the pin before pressing enter again.
How can I automate this in a batch file, or in powershell? I haven't been able to find any commands that work in a similar way to even get a start on it.
I am not sure if the trick below work with your particular program; but even in this case, if the program prompts for an additional input it must be placed inside the parenheses next to the pin number. Perhaps this is enough for your needs...
#echo off
(
echo pinnum
echo pinnum
) | tpmvscmgr.exe create /name "vSmartcard" /pin prompt /adminkey default generate

prompt in window for vbscript

I have a vbscript that runs on the command line in xp. It accepts one argument for the path to a directory. Is there a simple way to prompt the user in the command line box for this?
If not, I can just echo what was passed in to show the user what they actually typed in case of typos.
Thanks,
James
Aftermath:
Here is the code I ended up with:
On Error Resume Next
strDirectory = InputBox(Message, Title, "For example - P:\Windows\")
If strDirectory = "" Then
'Wscript.Echo cancelledText
Else
'Wscript.Echo enteredText & strDirectory
etc...
I found some snippets and it turned out to be really simple to work with the inputBox.
HTH.
James
You can use the WScript.StdIn property to read from the the standard input. If you want to supply the path when invoking the script, you can pass the path as a parameter. You'll find it in the WScript.Arguments property.
you can use the choice command, choice
it sets errorlevel to the value selected. I think it comes with DOS, Windows 95,98, then MS dropped it and then came back again in Windows 7 and probably Vista
P.D. oh never mind, I read again and you're in XP. There are other options, like set /p name= What is your name? would create a variable %name% you can use