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

How to add cookie to view a different web page

1 Answer 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 01 Apr 2012, 03:40 AM
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

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 03 Apr 2012, 10:24 PM
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
Tags
General Discussions
Asked by
Kevin
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or