Selenium ide: already logged in or not? - selenium-ide

I'm working with Selenium Ide 2.9.1.
The problem is to check if, beginning the automatic process, the user has already logged in.
So, on the first page of www.pageexample.com I need to check if id=welcome is JOHN SMITH.
If yes, the user has already logged in and then it's possible to go on with the following instruction (clickandwait | id=button10).
If not (I mean id=welcome is not present in the page), the login is needed (and in this case I've already built the instuctions).
I've installed Selenium IDE: flow control.

Taking a cue from the suggestion, I've elaborate the following code that seems to work:
storeElementPresent | id=loginbutton | x
storeElementPresent | id=sitename | y
gotoIf | x=y | z
....... operations of log in .......
label | z |
loginbutton is present only if the users has not logged in, sitename is always present (therefore always true): so, comparing the two values, in case of correspondence Selenium proceeds with the operation of log in, otherwise jumps to label z.
I know, it's an escamotage that can surely be improuved.

Related

VM Shutdown Order based on string in notes

I am trying to find the best way to use the notes field to set a shutdown order of virtual machines. At the moment, I have a note in my VM's as "Startup: X" where X is the number I want to use for startup, but the reverse being what I want for shutdown. The goal is to put this into a workflow so that machines complete their startup/shutdown before the next machine comes up.
Currently, I can get the info from the VMs by doing:
Get-VM | Where-Object {$_.Notes -contains "Startup:"} | Select-Object name,notes
It's my understanding that I want to put this into an object, then loop through that object based on the value after the ":" (e.g. 1, 2, 3, 4, 5, etc.) in either ascending or descending order. However, I'm not sure if that's the best method to work on this or not. All I know is that I want to look for the Startup: line in the VM Notes field, then use that alone to determine order. Some VMs might have other notes in them that I want to ignore, so I only want the Startup: string to show.
Could anyone give me some assistance? Or, let me know if I'm on the wrong path?
I have tried using multiple methods to parse, but I keep getting null errors that I cannot figure out. I'm fairly new to using PS in this way, so that doesn't help.

Execute single cucumber test case in a scenario outline using command line command

I want to execute single test case from a scenario outline using protractor.For example in the below Scenario Outline if I want to execute the test case TCID0002 alone, how I can run the test case TCID0002 using protractor?
#shopping
Scenario Outline: Test
Given the user navigates to xxx.com
When the user searches for <product>
Then the current page is shopping cart page
Examples:
|TCID | product|
|TCID0001|soap |
|TCID0002|watch |
|TCID0003|lipstick |
To run all the test case now I use
protractor Config.js --cucumberOpts.tags="#shopping"
Is there any command to execute single test case in the scenario outline ?
You can use tags on the examples table and splitting it into two tables. Then provide the #runone tag to tags option of cucumberOpts in config file.
#runall
Examples:
|TCID | product|
|TCID0001|soap |
|TCID0002|watch |
|TCID0003|lipstick |
#runone
Examples:
|TCID | product|
|TCID0002|watch |
Found solution to execute single test case in cucumber with a help of my team member.
To run single test case follow the below 2 steps
Step 1
Keep TCID in the scenario title as shown below
Scenario Outline: <TCID> test case to validate search
Given the user navigates to xxx.com
When the user searches for <product>
Then the current page is search result page
Examples:
|TCID | product|
|TCID0001|soap |
|TCID0002|watch |
|TCID0003|lipstick |
Step 2
Use cucumberOpts.name in your command. 'cucumberOpts.name' will filter the scenarios which contain the given string in the scenario title.
--cucumberOpts.name="WAGCAR0002" will filter the WAGCAR0002 scenario alone.
Command
The below command will execute the test case 'WAGCAR0002'
protractor Config/wagConfig.js --cucumberOpts.name="WAGCAR0002"

Powershell UIAutomation - how to identify methods supported by an object?

I'm just learning a bit of UIA with PoSH. So far so good, albeit somewhat basic.... I have worked out the following:
$np = get-uiawindow -class 'notepad' -name '*'
$npedit = $np | Get-UiaDocument
# $npedit | send-keys "abc"
$npedit | Set-UiaControlText "def"
$currtext = $npedit | Get-UiaDocumentRangeText
So then the next obvious stage was to automate driving ie, or chrome...
$ie = Get-UiaWindow -class 'ieframe' -name 'environment agenc*'
$addbar = $ie | Get-UiaPane -automationid '40966' -class "rebarwindow32"
$addbar | Set-UiaControlText "news.bbc.co.uk"
But it seems objects of class rebarwindow32 do not support "Set-UiaControlText".
Similarly, in my earlier experimenting, I also tried automating the windows calculator. Clicking buttons etc is easy enough, but trying to read the results of any calculation proved more challenging - the UIAutomationSpy showed it as a UiaText object of class "Static".
So all this is aimed at asking a fairly simple question - how can I identify what methods are supported by any one object - I'm not asking just HOW to get the current value in the calculator results, or HOW to set the IE browser address bar... but HOW to FIND OUT for myself, what methods any one object I have identified supports.
Everything I've googled so far has shown specific examples of "How to do this or that" (eg select a menu, set some text) - but all very specific.
Based on comments from mike z below, I've now tried GetSupportedPatterns, which (based on a bit of googling on GetSupportedPatterns, is exactly what I need!).
However, if (based on my sample code above) I do $np.GetSupportedPatterns() I get:
Cached Current
------ -------
UIAutomation.UiaWindowPattern+Window... UIAutomation.UiaWindowPattern+Window...
UIAutomation.UiaTransformPattern+Tra... UIAutomation.UiaTransformPattern+Tra...
Which doesn't seem to tell me very much - and I cannot widen my window? Also, why only the cached operations, rather than the full list?
Thanks
Steve

About iteration in Selenium IDE

I am newbie/beginner to Selenium IDE, i am running a test on a web application.
I wish to have a input of username into a textbox, let say 100 times how could i done this?
What i should type in the source or value column?
I want result somehow similar to
for (i=1;i<=100;i++)
{
value = "user" + i ;
}
(but i have no idea how to do it ...)
Then the test will going to loop 100 times and everytime will input different username like
User1 .... first time
User2 .... second time
Any helps would be appreciated. Thank you very much!
This approach should also work as well, using the SelBlocks extension.
for | i=1; i <= 100; i++ |
type | id=fieldname |user ${i}
endFor| |
You need to use parametrization with looping, you can refer
Selenium IDE: How to Pass Variables

SSRS Variable Expression - Sum, Sum, Scope?

I'm trying to write an expression for a variable (not parameter), so that I can use/reference it to do a calculation in another textbox. I have multiple datasets, and I need the SUM(SUM(Fields!amount.Value)) for each of these datasets. I am then going to use these numbers in another textbox, adding them with each other. I need some assistance with the syntax. I am able to use SUM by itself, without an issue. For example, this works fine:
=SUM(Fields!Amount.Value, "DataSet1")
But I get an error when trying to amend it to the following (which is what I actually need):
=SUM(SUM(Fields!amt.Value, "Acctrange_90300_90399_InterestExpenses"))
I get an error saying
"The variable expression for the report 'body' uses an aggregate
expression without a scope. A scope is required for all aggregates
used outside of a data region unless the report contains exactly one dataset."
I have a hunch that there's a problem with my syntax/parantheses placement. Any suggestions?
could you please provide a detailed example with maybe sample data and an expected solution?
Because I do not understand why you want to SUM(SUM()). The inner SUM() would result in a single integer value, why would you want to do another SUM on just a single value. even if it worked, it would just be the same value. I apologize if I understood the question wrongly, i can't comment, so i am answering, but I want to know clearly what you are looking for. I can understand if you are trying to do SUM( SUM(), SUM(), SUM()...). As in, sum of sums.
Sorry again for answering just to inquire more info, but I can't see a comment option.
UPDATE:
ok now i think you have something like
| a | b | c | d |
---------------------------
1 | * | * | * | * |
---------------------------
2 | * | * | * | * |
---------------------------
3 | * | * | * | * |
---------------------------
total | w | x | y | z |
so SUM(Fields!a.Value) would give you w, and SUM(Fields!b.Value) would give you x, and so on.
and you want w+x+y+z? If that is so, then you can do this:
add a calculated field to your dataset to calculate the row totals like
{ (a1+b1+c1+d1),(a2+b2+....), .... },
and then from your variable, call
SUM(Fields!CalculatedField.Value).
for above example, you can give the calculated field an expression as:
= CInt(Fields!a.Value)+CInt(Fields!b.Value)+CInt(Fields!c.Value)+CInt(Fields!d.Value)
this would make each entry in the calculated field as sum of each entry in all fields.
So sum of calculated field would give you your answer.
Hope thats what you wanted. Otherwise, well I tried understanding the problem. :)
Outer SUM needs a scope too. Try this:
=SUM(SUM(Fields!amt.Value,"Acctrange_90300_90399_InterestExpenses"),"Acctrange_90300_90399_InterestExpenses")
I expect this will also fail--in some new & different way--but that error will get you closer to a solution.
When SSRS wants to give me headaches like this, I cheat. I put the inner calculation in a hidden text box or name the box that displays it if I want it to show, then refer to it by name. So if I had the sum of the first column in a text box called txtFirstColumnSum, and the second column sum in the text box called txtSecondColumnSum, I'd use:
=cdec(ReportItems!txtFirstColumnSum.Value)+ cdec(ReportItems!txtSecondColumnSum.Value)...
Another way to do it is using the built-in scopes, but writing custom code to handle the math between the fields.
For example if I want the percentage of the current YTD sales over the same period the prior year, and also want to check for divide by zero, I can do it in an expression, but I use it on several levels, so instead I made custom code:
Public Function DeltaPercent(ByVal currentAmount as decimal,ByVal pastAmount as Decimal) as Decimal
Dim difference as decimal
Dim result as decimal
if pastAmount<>0 then
difference=currentAmount-pastAmount
result=difference/pastamount
else
result=0
end if
return result
End Function
Then to get the % change, I call it:
=Code.DeltaPercent(Sum(Fields!SalesYTD.Value, "SalesTerritory"),Sum(Fields!SalesPY1TD.Value, "SalesTerritory"))
One tip I wish I'd known sooner: If you use the syntax
ReportItems("txtFirstColumnSum").Value
you have to make sure you type it right. If you use the bang syntax (!) above, you get intellisense.