Adwisit / WADLibrary

MIT License
18 stars 11 forks source link

Users should be able to clean up specific sessions they created #2

Closed Aradesk closed 4 years ago

Aradesk commented 4 years ago

Hi,

Fist of all, thanks for your work on this Library. While fiddling with the keywords, i found myself with an error during clean_up()

def clean_up(self):
    for_deletion = self.__sessions
    for session in self.__sessions:
        self.delete_session(session.get_id())
    for session in for_deletion:
        self.__sessions.remove(session)

def delete_session(self, session_id):
        execute.delete(self.path + '/session/' + session_id)

In our context, we need to maintain some sessions/applications between testcases (clean_up() only gets called during testsuite teardown). If you use delete_session() to kill one application you're finished with, it still remains in self.__sessions and it's a problem later on when clean_up() is called.

I would like to propose this addition :

def clean_up_session(self,name):
        session = self.get_session(name)
        self.delete_session(session.get_id())
        self.__sessions.remove(session)
ghost commented 4 years ago

Hi!

Thank you for your suggestion! I've added the keyword and you should just need to update the package.

I hope it works for you and you are welcome to come back with other suggestions!

Aradesk commented 4 years ago

Thanks for the update, worked like a charm. Right now we're dealing with some issues on WAD itself (https://github.com/Microsoft/WinAppDriver/issues/446) but i'll let you know if we have some features/keywords that needs to be added.