Open a new window in IE and keep session

22 posts, 0 answers
  1. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 20 Oct 2015 Link to this post

    Hi,

    I read on this forum that there is no possibility to open a new tab in IE. OK, fine with that, but the question is now can I open new window and keep session from the first window? I have application which stores a session that is used all over the pages. ​I need to open a new tab/window and keep session from the first tab/window. SO in short I'm trying to replicate copy paste of the URL from first tab in the second tab and not loose session from the first tab. How can I do that?

    BR, Jurij

  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Oct 2015 Link to this post

    Hi Jurij,

    Specifically what we don't support is "Tabbed browsing" as shown in the attached screen shot. We do support multiple IE windows, just not tabs i.e. popup windows must open in a new window instead of a new tab.

    Does that answer your question?

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 21 Oct 2015 in reply to Cody Link to this post

    Hi Cody,

    Your missing the point of my question. I know that you don't support "tabbed" browsing and that is fine. But the core problem is that if I open a new window with menu option "Open in a new window" and then paste in URL from the first window, then browser session from the first ​window is still valid in the second window. If I open a new window then session from the first windows gets lost in the second one, when I use Telerik Test Studio to do similar as there is no option to choose "Open in a new window" when clicking on the link and right mouse button. For this I use the following code:

    // get URL
    string url = Manager.ActiveBrowser.Url;

    Log.WriteLine("-----------------------------------------------------");
    Log.WriteLine(url);
    Log.WriteLine("-----------------------------------------------------");

    // Launch a new instance of browser
    Manager.LaunchNewBrowser();

    // Navigate to extracted URL
    ActiveBrowser.NavigateTo(url);
    //Manager.Browsers[1].NavigateTo(url, true);

    Manager.SetNewBrowserTracking(true);
    {
        ActiveBrowser.Refresh();
        
        string payId = Convert.ToString(Data["paymentId2"]);
        
        HtmlFindExpression expr = new HtmlFindExpression("value=^" + payId);
        
        Log.WriteLine("------------------------------------------------------------");
        
        Log.WriteLine(Convert.ToString(expr));
        
        Log.WriteLine("------------------------------------------------------------");

        // Return all elements matching HtmlFindExpression name
        HtmlButton payment = Find.ByExpression<HtmlButton>(expr);
        
        Log.WriteLine(Convert.ToString(payment));
        
        Log.WriteLine("------------------------------------------------------------");
        
        ActiveBrowser.Refresh();
        payment.Click(false);
        
        Log.WriteLine("------------------------------------------------------------");
        
        Log.WriteLine(Convert.ToString(expr));
        
        Log.WriteLine("------------------------------------------------------------");
        
        Log.WriteLine(Convert.ToString(payment));
        
        Log.WriteLine("------------------------------------------------------------");
    }
    Manager.SetNewBrowserTracking(false);

    ActiveBrowser.Window.Minimize();

    Manager.Browsers[0].Window.SetFocus(); 

    ActiveBrowser.Window.SetFocus();

    ActiveBrowser.Close(30);​

     

    BR, Jurij

  4. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 21 Oct 2015 in reply to Jurij Link to this post

    Another thing, you have documented here how pop-ups work. Unfortunately in my case when I record a pop-up and then run this test it doesn't open a pop-up at all. How so?

    BR, Jurij

  5. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 21 Oct 2015 Link to this post

    Hello,

    Your missing the point of my question.

    Ok, I was a little worried if I was answering the right question. That's the very reason I closed with "Does that answer your question?" So thank you for the clarification.

    Looking at your code I think the problem you're running into is that Manager.LaunchNewBrowser launches IE using the -noframemerging option as described here. This has the effect of preventing session merging. Thus the new window will act like a brand new session to the web server.

    Unfortunately in my case when I record a pop-up and then run this test it doesn't open a pop-up at all.

    This is a completely different problem, for which I have no explanation. Can you send me an already recorded test I can execute on my machine that reproduces this problem? Once I can reproduce it I can investigate the root cause of the problem. Also, since this is unrelated to this forum thread, a new thread, or private support ticket should be opened on it.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  6. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 22 Oct 2015 in reply to Cody Link to this post

    Hi Cody,

    Sorry if I was rude, it wasn't my intention. Now I was able to record a video of the problem I have, so please check it out on https://jurij-dhimahi.tinytake.com/sf/MzQ5Nzk1XzIwMjI1MzU. In the video you will exactly see what I need to achieve.

    BR, Jurij

  7. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 22 Oct 2015 in reply to Jurij Link to this post

    I also forgot to mention that once I have two windows open I want to do something in one and then switch to another and do something there. Based on that session is not lost in a new window.

    BR, Jurij

  8. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 22 Oct 2015 Link to this post

    Hi,

    Based on that session is not lost in a new window

    That cannot be achieved with Test Studio. The new window will be a new session, a new set of cookies, from the web servers point of view. It will appear as "logged out" or disconnected from the original browser window.

    You can switch back and forth between windows, but even that requires code, something similar to this code sample. All non coded test steps will only work on the "active browser" which is defined as the last browser window that was opened and connected to by Test Studio.


    I now understand your question/problem with "where is the popup" question. When you did the second Run To Here on step 6, the connect to popup window step, none of the steps prior to it caused a new window to open. The Connect to Popup window assumes a new browser window was just opened up in the step before it.

    In reality you used a Right click and selected "Open Link in New Window" when recording. This right click action and menu selection was NOT recorded by Test Studio. Thus there's no test step that does this action during playback. As a result, during playback, no action was performed to cause a second window to open. The connect to popup is expected to fail for lack of a new window to connect to.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  9. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 23 Oct 2015 in reply to Cody Link to this post

    That cannot be achieved with Test Studio. The new window will be a new session, a new set of cookies, from the web servers point of view. It will appear as "logged out" or disconnected from the original browser window.

    So you are saying that I cannot repeat what I have done while recording? Is there any way to this then with the code? Namely as you can see in the video the session is preserved in a new window, when I choose Open link in a new video and then copy URL from the first window to newly opened.

    In reality you used a Right click and selected "Open Link in New Window" when recording. This right click action and menu selection was NOT recorded by Test Studio. Thus there's no test step that does this action during playback. As a result, during playback, no action was performed to cause a second window to open. The connect to popup is expected to fail for lack of a new window to connect to.

    How can I record this then in Test Studio or there is no option to record right click -> open link in new window step in Test Studio at all?

    BR, Jurij

     

  10. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Oct 2015 Link to this post

    Hello,

    Test Studio does not record Right Clicks at all under any condition. It is not capable of recording this action. To further complicate matters, the popup menu you get on the right click is a browser popup menu. It's not part of the HTML of the page being displayed. This means Test Studio also cannot even see that popup menu, let alone what you're left clicking on to select a menu item.

    Now if you want to experiment, there is a way to add manually what we call "blind mouse clicks" to an existing test script. Maybe this way you can get what you're after.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  11. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 26 Oct 2015 in reply to Cody Link to this post

    Thanks for pointing me to blind mouse click, which I already found on Friday and used successfully. Currently I'm now able to open a new window, but now I have another problem on how to change between two open windows (pop-up and original window) and do some action in one and then in another. Any solution to that?

    BR, Jurij

  12. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 26 Oct 2015 Link to this post

    Hi Jurij,

    From my 22-Oct-2015 reply:
    You can switch back and forth between windows, but even that requires code, something similar to this code sample. All non coded test steps will only work on the "active browser" which is defined as the last browser window that was opened and connected to by Test Studio.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  13. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 27 Oct 2015 in reply to Cody Link to this post

    True and saw that already. But that is useful only if you launch another instance of IE, where data from first one gets lost. What about the following:

    1. Open IE

    2. Do some stuff

    3. Open another IE (using Open link in a new window)

    4. Do some stuff in newly opened window

    5. Close it

    6. Do some stuff in first IE instance

    Based on your comments that is not possible to test with Test Studio?

    For example I managed to get another window opened with the following commands:

    1. Navigate to "/"
    2. ...
    3. Wait for Exists 'YourEmailLabelTag'
    4. Desktop command: RightClick on TicketsForImage
    5. Wait for '2000' msec.
    6. Desktop command: LeftClick on PlaceOrderListItem (using "blind mouse click")

    The above opens new window with no data lost from first window. But now I have problem how to get focus on this newly opened window and do some stuff in it. Any suggestions?

    I sure hope that I'm not the only one with such testing scenario and that this is not out of Test Studio's scope.

    BR, Jurij
  14. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 27 Oct 2015 Link to this post

    Hi Jurij,

    The sequence you just described is actually easier because you're not trying to switch back to the first opened window to do something while working in the second opened window. You're just missing one step in your sequence:

    1. Navigate to "/"
    2. ...
    3. Wait for Exists 'YourEmailLabelTag'
    4. Desktop command: RightClick on TicketsForImage
    5. Wait for '2000' msec.
    6. Desktop command: LeftClick on PlaceOrderListItem (using "blind mouse click")
    7. Connect to Popup

    As long as Test Studio successfully connects to the second window then it can successfully interact with it.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  15. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 27 Oct 2015 in reply to Cody Link to this post

    Hi Cody,

    7. Connect to Popup​

    I did this as well (Connect to pop-up window : '/' - DataDriven: [$(extractedURL)]) and also binded "PopupUrl" to data driven variable extractedURL, but still it doesn't want to connect to this pop-up... Sorry but something so simple (at least it should be) is driving me nuts and is jeoparding our QA process!

    Hopefully someone has a solution, even if it is in code.

    BR, Jurij

  16. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 27 Oct 2015 Link to this post

    Hello,

    Can you send me a small test project in which I can execute the test on my machine to reproduce the problem? I'll have a look and see if I can make it work the way you want it to.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  17. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 28 Oct 2015 in reply to Cody Link to this post

    Hi Cody,

    I can't send you our app project files and even grant you access to it due to our company security policies. However I can repeat the same problem on www.google.com page and therefore I have attached the project where I have the same problem using Google page.

    BR, Jurij

  18. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 28 Oct 2015 Link to this post

    Hi Jurij,

    Thank you for the project. Here's a video showing you what I did to make it work the way you want it to:
    http://screencast.com/t/SHCVXVOMxS7

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  19. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 29 Oct 2015 in reply to Cody Link to this post

    Hi Cody,

    Thanks for the help, but this solves my problem partially now. I do get now pop up open, but I can't do anything with it. See the following video https://jurij-dhimahi.tinytake.com/sf/MzU5NjE5XzIwNjA4MDQ of my problem and I apologise for not having audio. Hopefully it is clear what my next problem is.

    BR, Jurij

  20. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 29 Oct 2015 Link to this post

    Hello Jurij,

    I believe the problem you're running into is caused by the URL specified in your Connect To Popup window on step 12. You probably have "IsUrlPartial" checked which tells TS to connect to the first window that contains "/". Unfortunately the URL of the first opened window matches, i.e. contains "/", and thus TS is "incorrectly" re-connecting to the first window instead of skipping it as it "doesn't match" and looks for a second browser window that does match.

    If instead you set the URL of this step to something unique to the second window e.g. "/en/" and leave "IsUrlPartial"   checked should do the trick.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  21. Jurij
    Jurij avatar
    54 posts
    Member since:
    Sep 2013

    Posted 30 Oct 2015 in reply to Cody Link to this post

    I don't remember when I was so excited!!! THANK YOU THANK YOU, IT WORKS!!!

    I can finally continue with my tests!!! I can't say thank you enough!!!

    BR, Jurij

  22. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 30 Oct 2015 Link to this post

    Hi,

    That's wonderful! Thank you for the update.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top