Telerik Forums
Test Studio Forum
2 answers
190 views
Hi,

Another question that will doubtless be easily answered by someone who knows what they're doing.

Scenario
I want my script to branch depending on the value I can retrieve from a databound Excel spreadsheet cell.

I know how to get the value from the cell using this VB in the Code Behind window, and I can set it as an extracted value available to the Test Studio script with the last line:

Dim row As Integer = 2
Dim column As Integer = 4           
Dim input As String = "C:\Users\edwardni\Documents\Test Studio Projects\Base\Data\BaseData.xlsx"           
Dim app As New Microsoft.Office.Interop.Excel.Application()
Dim inputBook As Microsoft.Office.Interop.Excel.Workbook = app.Workbooks.Open(input, 0, False, 3, "", "", False, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", True, False, 0, True, False, False)
Dim inputSheet As Microsoft.Office.Interop.Excel.Worksheet = DirectCast((inputBook.Worksheets.Item("SetupAllRoles")), Microsoft.Office.Interop.Excel.Worksheet)
Dim selection As String = TryCast(DirectCast(inputSheet.Cells(row, column), Microsoft.Office.Interop.Excel.Range).Text, String)
SetExtractedValue("IsAdmin", selection)

Required Solution
What I want to do in the script is to have an IF... Else statement like this:

IF ($(IsAdmin) = "Y")
     <do some stuff>
ELSE
     <do some different stuff>

But I don't know how to build the above structure in the script itself.  There is nothing I need to record against so I have nothing to convert to a logical step.

All responses gratefully received,
Nigel Edwards, Transition Computing.
Nigel
Top achievements
Rank 2
 answered on 05 Mar 2012
6 answers
181 views
The recorder was taking up to 60 seconds to connect to browser pop up windows. I have just upgraded to the latest release and now the recorder will not connect to browser pop-ups, I timed it up to 200 seconds and it continued to show the connecting view, after clicking close on the connection it then crashes the browser session. The product is now unusable for a large part of my application and I will have to revert back to the previous version until it is resolved.

Thank you
Ivaylo
Telerik team
 answered on 02 Mar 2012
3 answers
254 views
Hi,

Anthony provided what looks like a nice solution to a problem I raised (http://www.telerik.com/automated-testing-tools/community/forums/test-studio/general-discussions/finding-and-clicking-dynamic-buttons.aspx), but when I try to implement it my script fails to run.  The log shows this error:

WaitForLogoutButtonAvailable.tstest.vb: Line 81: (BC30491) Expression does not produce a value.
This is the VB sub:

        Public Sub WaitForLogoutButtonAvailable_CodedStep()
            Dim found As Integer = 0
            Dim s As HtmlSpan = Find.ByExpression(Of HtmlSpan)("textcontent=~logout")
            While found = 0
                If (Assert.IsNotNull(s)) Then
                    'Stop looking
                    found = 1
                Else
                    'Wait for '250' msec.
                    System.Threading.Thread.Sleep(250)
                End If
            End While
        End Sub

I tried exchanging the statement:
     If (Assert.IsNotNull(s)) Then
for:
     If (Assert.IsNotNull(s) = true) Then
but I get the same result.  I also tried with various speechamrks, 1's and 0's.  I read the on-line documentation (http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/html-control-suite/html-asserts.aspx, and also http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/intermediate-topics/element-identification/findparam-objects.aspx) but the pages don't actually show me what is returned by the assert.

Where am I going wrong?

Thanks,
Nigel Edwards, Transition Computing

 
Nigel
Top achievements
Rank 2
 answered on 02 Mar 2012
1 answer
187 views

I have the following code that searches a table that can be indexed by pages.  What I do not know what is the return value of myTable.Find.ByContent when the search string is not matched.  Also what’s a slick way to do an index search in the pages till the string is found.  I want to mimic what a user would do in index.

Thanks,

John

Dim MySearchString as String
MySearchString = "Start All over III"
 
 
 
' Copy the table into a local variable to make it easier to work with
Dim myTable As HtmlTable = Pages.JointCommissionResources9.CphTracerPageRadMyOrgTracesTable
' Locate the row we want using text content (Enter the String to search by
Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)(MySearchString).Parent(Of HtmlTableRow)()
 
' Locate the delete icon (which is going to be just an anchor tag) located in the third column of the current row
'Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnEditResponse")
'uniquename="UrgbtnNewResponse"
Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnNewResponse")
'Dim link As HtmlAnchor = row.Cells(4).Find.ByExpression(Of HtmlAnchor)("value=Print/Preview")
' Now that we've found it, click the delete icon
link.Click()
 
HtmlTableCell Find By Search String
 
Dim MySearchString As String
Dim PageNumber As Integer
 
 
MySearchString = "this is a new tracer"
Log.WriteLine("Value: " & MySearchString)
Log.WriteLine("Pages: " & GetExtractedValue("x2StrongTag").ToString())
 
 
 
' Copy the table into a local variable to make it easier to work with
Dim myTable As HtmlTable = Pages.JointCommissionResources9.CphTracerPageRadMyOrgTracesTable
Log.WriteLine("Table when Nothing found: " & myTable.ToString)
 
' Locate the row we want using text content (Enter the String to search by
'Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)("Article B01").Parent(Of HtmlTableRow)()
 
 
 
Dim row As HtmlTableRow = myTable.Find.ByContent(Of HtmlTableCell)(MySearchString).Parent(Of HtmlTableRow)()
 
' Locate the delete icon (which is going to be just an anchor tag) located in the third column of the current row
'Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnEditResponse")
'uniquename="UrgbtnNewResponse"
Dim link As HtmlAnchor = row.Cells(5).Find.ByExpression(Of HtmlAnchor)("uniquename=UrgbtnNewResponse")
'Dim link As HtmlAnchor = row.Cells(4).Find.ByExpression(Of HtmlAnchor)("value=Print/Preview")
' Now that we've found it, click the delete icon
link.Click()

Anthony
Telerik team
 answered on 01 Mar 2012
1 answer
83 views
I was wondering can I use Test studio to test other than User Interface layer? Like I want to test server layer and data access layer.
Thank you in advance
Ivaylo
Telerik team
 answered on 01 Mar 2012
2 answers
427 views

Hi,
I need help to find and identify screen objects whose name changes.
Specific Scenario Example
I have a screen with a Logout button.  The visible text on the button is 'Logout ' plus the name of the logged on user (e.g. 'Logout Admin').  When I record the action of clicking on the button in Test Studio the script supplies a line that reads:
   
Click 'LogoutSpan'
or
   
Click 'LogoutSpan0'
or similar.
Question
How can I script so that the action works regardless of any number that may be appended to the 'LogoutSpan' part?
In fact, how can I identify anything (e.g. a 'Div') where its name or ID changes dynamically?

I thought that maybe some VB in the Code Behind window would be a solution, perhaps using a regular expression.  In the case of the button I came up with:

    Find.ByExpression("name=~Logout")
which I think will find any screen object with 'Logout' in its name, but got no further.  I tried to write an excution line, something like:
   
Button.Click(Find.ByExpression("name=~Logout"))
but the type-ahead prompt in the Code Behind window didn't have 'Button.Click' as an option.

I'm not a code wizard, and don't really understand regular expressions (and yes, I've read the available on-line documentation) so I would very much appreciate some help with this.  If I have a concrete example of how to resolve the above then I can build on it for the future.

Thanks,
Nigel Edwards, Transition Computing.

 

 

Nigel
Top achievements
Rank 2
 answered on 01 Mar 2012
1 answer
108 views
I am attempting to set up our schedule server and am running into the error "Unable to register machine! Error:" when I attempt to register the local machine. I have administrative access to the machine as well as the database. The database is also a fresh install exclusively for telerik use. I checked the logs through the event viewer for TelerikWebUIServiceSourceLog and there was an error reported there that reads:

Client register machine request failed: Object reference not set to an instance of an object. at Telerik.TestStudio.Scheduling.WindowsService.ScheduleManager.RegisterMachineClient(String& error, Machine machine)

Any suggestions on going about fixing this would be greatly appreciated!
Brad
Top achievements
Rank 1
 answered on 01 Mar 2012
1 answer
178 views
I am having some problems with tests when i attempt to schedule them and the execution server is running on a machine that is currently locked. The tests run fine when run manually of if I have the machine unlocked that is running the execution server. It doesn't seem to activate javascript elements the same way which is causing certain parts of the page to not be enabled. Has anyone had problems like this and if so how did you get around them.
Thanks
John
Anthony
Telerik team
 answered on 29 Feb 2012
1 answer
95 views
Hi

I see from some other posts that the current version does not allow recording of test outside IE
Are there any plans to change this as many projects are not using IE as there main browser

Aidan
Ivaylo
Telerik team
 answered on 29 Feb 2012
5 answers
245 views
I upgrade Test Studio to 2011.2.1413.0 and found that one of Elements in Element Explorer disappeared.

It presents in Pages.cs
public ArtOfTest.WebAii.Controls.HtmlControls.HtmlAnchor Link_Contacts
{
    get
    {
        return Get<ArtOfTest.WebAii.Controls.HtmlControls.HtmlAnchor>("class=ms-crm-NavBar-Subarea-Link", "title=Contacts");
    }
}
but there is no such element in Element Explorer
http://screencast.com/t/BbKtOrF049f

How could I fix it?
Plamen
Telerik team
 answered on 29 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?