Building a statement

2 posts, 1 answers
  1. Chris
    Chris avatar
    17 posts
    Member since:
    Sep 2011

    Posted 01 Dec 2011 Link to this post

    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
  2. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 02 Dec 2011 Link to this post

    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
Back to Top