How to add cookie to view a different web page

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    9 posts
    Member since:
    Jul 2012

    Posted 31 Mar 2012 Link to this post

    Hi team,
    i met an issue about cookie today. In my web application, there is a debug page("http://wwwqa.inventory.ford.com/debug/cookies.jsp") to add a cookie with name "dealerPooling" and value "true", if i add this cookie, then a proper page will display.
    My version of  telerik test studio is 2011.2.1413.0

    scenario 1:
         step1: turn to "http://wwwqa.showroom.ford.com/FDShowroom.jsp?makeTransition=inventory"
         step2: click on FIESTA image
         step3: input a zipcode(48033) to zipcode input textbox and click "SEARCH DEALER INVENTORY" button
         step4: A search dealer inventory page for this scenario1 will display

    scenario 2:
         turn to a debug page "http://wwwqa.inventory.ford.com/debug/cookies.jsp" and add a cookie with name "dealerPooling" and value "true"
         repeat steps in scenario2, and we can see a different search dealer inventory page for this scenario2.

    What i want to know is how to add cookie with code steps?
    I have tried several ways to do that, but failed, only scenario1 page displayed when i execute scenario2 step, here is some code to be invoked before clicking "SEARCH DEALER INVENTORY"

    1.
    Public Sub SetCookie()
                Dim newCookie As New System.Net.Cookie()
                newCookie.Name = "dealerPooling"
                newCookie.Value = "true"
                newCookie.Domain = "http://wwwqa.inventory.ford.com"
                newCookie.Expires = DateTime.MaxValue
                ActiveBrowser.Cookies.SetCookie(newCookie)

    End Sub

    2.
    Public Sub SetCookieWithDebugPage()
                ActiveBrowser.NavigateTo("http://wwwqa.inventory.ford.com/debug/cookies.jsp")
                
                Dim nameBox, valueBox As HtmlInputText
                Dim submitButton As HtmlInputSubmit
                
                nameBox = Find.ByAttributes(of HtmlInputText)("name=newName")
                valueBox = Find.ByAttributes(of HtmlInputText)("name=newValue")
                nameBox.Text = "dealerPooling"
                valueBox.Text = "true"
                submitButton = Find.ByAttributes(of HtmlInputSubmit)("name=addCookie")
                submitButton.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop)
                submitButton.Click
    End Sub
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 03 Apr 2012 Link to this post

    Hello Kevin,

    This is a duplicate of your other forum post. Let's continue the discussion there.

    All the best,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top