How to create new browser session using UiPath test automation

Hello all,

I am new to UiPath Test Automation. If I am trying to execute same test more than one time, browser is saving the cache and when I reexecute again the session contains old cookies even I check ‘NewSession to True’.
Can any one help me how to create new session for each execution

Hi!

Have a view on this

Regards,
NaNi

@THIRU_NANI
But when you take Selenium or other automation tools, when we execute more than one test cases it will create separate sessions for each test case.

  1. Lets execute my test case name Test_A(Work flow: Login, Home page validation, user validation)
  2. Lets execute my second test case Test_B(Workflow: Login, Registration page validation)

When I run second test cases in UiPath will lunch the browser with old session (by default application loging in). this should not be the case. when you execute next test case or next run browser should lunch with new session.

Before getting to second step or second process did we try to close the browser session in first step itself

It is always a good practice to close the application been used in a session before bot stops

So here in your case close the browser session or any application you are using for each individual run and then try with next run
It won’t come

Cheers @viuppulu

Hi!

@Palaniyappan Actually it’s an good idea. but in this case he’s log in to the application. The close Browser\Application will close the browser but when it comes to the website the login will stays.

@viuppulu

In this case can we add logout workflow? when new session is encountered this will starts from scratch.

Regards,
NaNi

@Palaniyappan ,

Yes, I am closing the browser by using CloseTab activity at the end of the test case. Even I close the browser, application is loading with logged the user.

@THIRU_NANI ,

We can add logout, but my worry is when we start next round of execution or next test case manually why the previous session is loading.
I am closing the browser after test case workflow done.

Hi,
In our team we always follow, as best practice:

  1. Open Browser: select private mode + new session options + create browser variable
    image

  2. Log In

  3. Log Out

  4. Close tab: so, browser.element variable to refer exactly to the session you just have created
    image

By this way you’ll always refer to the session you’re working on

I think you can then try with Private browsing option as it doesn’t save any caches

For that choose as Private in property panel of that activity

That should be working fine

Cheers @viuppulu

Hi!

You can try with Private inside the open browser activity!

in order to use private(Incognito) we must enable the browser extension as Allow in Incognito inside the browser extensions.

Reference:

Regards,
NaNi

Same settings I have followed after your reply.
Just browser launched with application url and then nothing happened finally throwed an error

21.10.4+Branch.master.Sha.8f864e3db4251aecabea63041087de2634460029

Source: Enter UserName

Message: Could not find the UI element corresponding to this selector:

Exception Type: UiPath.Core.SelectorNotFoundException

RemoteException wrapping UiPath.Core.SelectorNotFoundException: Could not find the UI element corresponding to this selector:

at UiPath.Core.Activities.ObsoleteTaskAsyncCodeActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@THIRU_NANI

Thanks for the info. I have changed the properties as per above screenshot. It’s working in Private mode.
Apparently ,normal browser should launch a new session every time right?

Hi!

Yes. we can also use new session in private mode as well.

by setting the NewSession=True

Regards,
NaNi

@THIRU_NANI ,

For Private browser does not require to set true because private browser will not save cache.

Normal browser is not creating new session.

Looks like no solution yet with the existing version

Yeah that’s right

But still did we try with other browsers as well

@viuppulu