Answered

Is there a way to close and disconect from all windows

When executing a Subject7 test it is desired to close and disconnect from all windows/tabs/popups.   Basically, I want to restart a session from scratch in the middle of a test.

Is there a function/method for this?  I am looking for something other than clearing Browser history.   While I have a method to do that, clearing history is awkward on a local run as the mouse has to be in the Subject7 session active window.

 

0
18 comments
Avatar
Joseph Hamdan

Hi William,

Thank you for creating a post. Would you please let us know more about the use case behind this? 

Does the browser history/cache create any issues in your execution? 

How many tests are we talking about and what's their average length in steps?

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
William Smith

There is a new system in place where before I log into the application I need to log into another page first, then log into the application.   We will call the other page the permissions page.   The permissions page has no log out button, so once I log in I cannot log out. 

I could clear the cache as mentioned, but that would involve making sure that my mouse focus remained on the application web page during a local run.   This is not an issue during a cloud run.   What I would like to do is terminate the session and restart it which would also clear the cache.

Another way to look at it, is that I would like to restart my session from scratch in the middle of a test.

 

0
Comment actions Permalink
Avatar
William Smith

The purpose of the break is to be able to log in as another user during the test.

 

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

I see that you created this post a while back which also refers to clearing cache. 

https://subject7.zendesk.com/hc/en-us/community/posts/1500001336042-Clearing-the-web-browser-cache-from-Subject7

I have made a modified smaller test below that you can use to clear cache during execution, when you run it, it will log into a user on Social Network app and once cache is cleared, the page will refresh and the user will no longer be in session:

WEB GOTO_URL "https://reference.subject-7.com" HALT ON ERROR 
CALL FUNCTION subject7_reference_login HALT ON ERROR 
WAIT 3 HALT ON ERROR 
DESKTOP HOTKEYS MONITOR "1" CTRL,SHIFT,DELETE SYNC_LOCK_KEYS true TARGET FOCUSED_ELEMENT HALT ON ERROR 
WEB SWITCH WINDOW BY POPUP "Settings" DURATION_TYPE WHOLE_TEST_CASE HALT ON ERROR 
WEB EXECUTE SCRIPT "document.querySelector('settings-ui').shadowRoot\n .querySelector('settings-main').shadowRoot\n .querySelector('settings-basic-page').shadowRoot\n .querySelector('settings-privacy-page').shadowRoot\n .querySelector('settings-clear-browsing-data-dialog').shadowRoot\n .querySelector('cr-dialog[id=clearBrowsingDataDialog]')\n .querySelector('cr-button[id=clearBrowsingDataConfirm]')\n .click();" LOCATORS HALT ON ERROR 
WEB SWITCH WINDOW BY MAIN DURATION_TYPE DEFAULT HALT ON ERROR 
WEB CLOSE POPUP CLOSE_ALL_EXCEPT_MAIN HALT ON ERROR 
WEB HOTKEY CTRL_F5 HALT ON ERROR

Please let me know if you have any questions.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
William Smith

Yes, and I I mentioned, I use a clear cache function for some tests.   The trouble with that option is that on a local run, the mouse focus has to stay in the execution window for it to work.   That is ok for what we were doing previously as it was for a limited number of tests.

Now this is for all of our tests, and I would prefer not to use the clear cache function.  If I do every time a do a local run of a test, I basically have to not touch my mouse.  

I am assuming from the responses that Subject7 does not have a good way to disconnect the session.   That is what I needed to know.

Thanks

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

Thanks for clarifying this further. We understand the challenge that your are facing and would love to provide you with the best solution.

With current implementation, it's not possible to end the session in the middle of a local execution then start another.

However, we can definitely look into this further, would you please let me know the impact that this has on your tests? How many tests are affected by this?

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

One additional question, does deleting cookies solve the issue, or the entire browsing history and cache has to be deleted as well?

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
William Smith

So, I deleted just cookies/data and the session did not clear.  I cleared just the cache and the session cleared.  So it appears that I need to clear the cache. 

 

Also, with regard to the previous question.  This impacts most of my tests.   I suspect more sites will be moving into MFA scenarios, so it would be useful to come of with ways to handle this.  I am not exactly sure what that means with regard to Subject7.

 

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

Thanks for confirming the details. We will provide an update as soon as possible.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Rex Feizi

Hello William,

Thank you for sharing your experience with clearing cookies/data and cache. For ease of reference let me organize this in numbers: 

1. It would be helpful if you can share with us the method of authentication used in the application. Is this done via cookies with something like jsessionID or some other mechanism? Developers of the application should be able to provide you with that information. 

2. Also may I ask how did you use the delete cookie command specifically? 

3. Regarding MFA, it is not recommended to automate Multi-Factor Authentication (MFA) or Two Factor Authentication (2FA) using automation bots. Although there are ways to automate MFA, it defeats the purpose of its existence and introduces a big vulnerability in the organization. Automated logins will not be traceable to a real person and can compromise the security of the target application.

Instead of automating MFA, it is recommended to consider other measures to further protect the target application, such as creating service accounts, restricting access to a static source IP, or using other connection mechanisms to secure access. These measures can help ensure the security of the target application and reduce the risk of compromise.

 

0
Comment actions Permalink
Avatar
William Smith

So I would like to run another thought on this discussion.

 

I am now creating testing for some MSPP applications.  Due to their nature, in order to use test accounts with these applications I need to run my testing in incognito mode.   What I am running into now is that the only way to totally clear a user and re-log in as another user is to close the incognito window and start a new one.  

When I try to issue a cache clearing function to the incognito window, a popup appears to close the window.  When  that is done, Subject7 loses connection and the test fails.

 

Any ideas for workarounds for this?

 

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi William,

Do you mean this window?

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
William Smith

Yes, that one.

 

0
Comment actions Permalink
Avatar
William Smith

So I guess we are stuck on this one since Subject7 doesn't not have a way to restart the window?

 

0
Comment actions Permalink
Avatar
William Smith

So, another option I have been looking at is to open a new incognito window from the existing window then switch to that using the "SWITCH_WINDOW" command.

The documentation for that command suggests using the javascript command 

window.open("https://reference.subject-7.com") then switching to it.

I tried this which I determined to be correct syntax:

window.open("https://reference.subject-7.com", "incognito") but that just opens a new tab in the current window.   Any ideas on how to actually have windows.open() create a new window?

0
Comment actions Permalink
Avatar
Jonathan Hotz

Try adding "_blank" to the list of parameters in the window.open command. I did a quick test in the console and it opened in a new window and not a tab of the current window.

0
Comment actions Permalink
Avatar
William Smith

The _blank still did bring it up in a new window, but I couldn't get it to start in incognito mode.  I did decide I could make this work by sending a <ctrl><Shift>N using Desktop_Hotkeys.   Not ideal, but it works.

 

Thanks.

0
Comment actions Permalink

Please sign in to leave a comment.