Closed zahraazezo closed 3 years ago
What is the command time out given?
@anunay1 It was 60 seconds , I changed it to be 120
new WindowsDriver
as it was always throwing The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/session/C31E5E62-EB73-4392-A659-063F46FE1F11/element timed out after 60 seconds. exception while locating any element using xpath
xpath is slow and that's a known issue with WAD, better to use other method to find the element. I have not used it all all in my project.
@anunay1
Thank you so much for reply
I know , unfortunately there are nested elements that I need to locate and I have to use xpath to locate them
, but I want to know why it sometimes t runs fast even with xpath (not fast as the other locators , but in accepted way ) and sometimes not ?
@zahraazezo What I have observed is that winappdriver caches older sessions which were not terminated properly with quit()
method.
From python, I can list all older sessions by driver.all_sessions
property.
What I am doing to avoid this is to close all older sessions at test start.
# Appium stops responding after several runs. It is because it stores old sessions data which makes it laggy.
# To avoid this issue, clear old sessions at the first session initiation request
if self.is_desktop and UiDriver.dump_old_desktop_sessions:
current_session_id = session.session_id
old_sessions = list(filter(lambda i: i.get('id') != current_session_id, session.all_sessions))
for it in old_sessions:
session.command_executor.execute(Command.QUIT, {'sessionId': it.get('id')})
I think restarting winappdriver before each test should also do the job
@shoaibmansoor Sorry for my late reply , you are right .it worked for me Thank you so much
Am using C# Visual Studio for Desktop Automation using WinApp session, But it is taking more time to find an Element. But am not using any wait or Thread.Sleep. But the OverAll Test Cases is taking more time. Any Solution or alternative for this???
What's more time? How much time does it take. What is the command timeout you have given?
It is taking more than 10 seconds to find an element in the page. I didn't give any timeout command.
By default the timeout is 60 seconds.
Am using C# Visual Studio for Desktop Automation using WinApp session, But it is taking more time to find an Element. But am not using any wait or Thread.Sleep. But the OverAll Test Cases is taking more time. Any Solution or alternative for this???
Try this https://github.com/microsoft/WinAppDriver/issues/1472#issuecomment-1121094052
@shoaibmansoor , I am getting error when I try to use this code. What are these variables? there is no method called driver.all_sessions. Would Greatly appreciate your help.
# Appium stops responding after several runs. It is because it stores old sessions data which makes it laggy.
# To avoid this issue, clear old sessions at the first session initiation request
if self.is_desktop and UiDriver.dump_old_desktop_sessions:
current_session_id = session.session_id
old_sessions = list(filter(lambda i: i.get('id') != current_session_id, session.all_sessions))
for it in old_sessions:
session.command_executor.execute(Command.QUIT, {'sessionId': it.get('id')})
When running WinAppDriver automated tests , it runs fast sometimes and slow most of times , informing that there are no other running application .