This is a migrated thread and some comments may be shown as answers.

Building a statement

1 Answer 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 02 Dec 2011, 12:21 AM
I'm sure there is a command in Visual Basic, but I'm not sure what it is.

I have this VB code that builds a command but while I can get the command to display in the console, I can not figure out how to get the code to execute in the code behind file.

Here is the code:
Dim intMonth As DateTime = DateTime.Now.AddDays(-1)
Dim format As String = "m"
Dim strMonth as String
strMonth = (intMonth.ToString(format))
strMonth = strMonth.Replace(" ", "")
Console.WriteLine("Pages.OrchidTest0."+strMonth+"Link"+".Click(false)")

and what I want to execute (for today for example) would be:

Pages.OrchidTest0.November30Link.Click(false)

Thank you in advance
Chris

1 Answer, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 02 Dec 2011, 06:28 PM
Hello Chris,

This scenario is close to Data Driven Find Expressions. Instead of feeding the Find Expression a value from the data table, you'll be clicking a link based on its content matching a string containing yesterday's date. Try this code instead:

Dim intMonth As DateTime = DateTime.Now.AddDays(-1)
Dim format As String = "m"
Dim strMonth As String = Nothing
strMonth = (intMonth.ToString(format))
strMonth = strMonth.Replace(" ", "")
 
Log.WriteLine(strMonth)
 
'Find and define the link based on its content matching yesterday's date
Dim myAnchor As HtmlAnchor = Pages.OrchidTest0.Find.ByContent(Of HtmlAnchor)(strMonth)
Assert.IsNotNull(myAnchor)
myAnchor.Click()
 

Best wishes,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 2
Answers by
Anthony
Telerik team
Share this question
or