I'm doing some desktop application testing using Winium with Python. For my application, I'm first confirming the progress bar appears on the windows with some other text. I'm then confirming the progress bar no longer exists before continuing forward.
running_app = driver.find_element_by_name("MyApp")
status_bar = running_app.find_element_by_id("statusStrip1")
status_bar.find_element_by_class_name("WindowsForms10.msctls_progress32.app.0.141b42a_r9_ad1")
status_bar.find_element_by_name("Loading Default Files...")
# Confirm Progress Bar disappears before continuing
WebDriverWait(driver, 60).until_not(
expected_conditions.presence_of_element_located((eval("By.CLASS_NAME"), "WindowsForms10.msctls_progress32.app.0.141b42a_r9_ad1"))
)
The issue I'm having is with the portion of the code that's meant to verify the Progress Bar has disappeared before continuing on. That particular line takes too long to execute. After some investigation, I concluded this is happening because I'm only able to feed the component address into 'presence_of_element_located' as opposed to its full address, which would look something like...
driver.find_element_by_name("MyApp").find_element_by_id("statusStrip1").find_element_by_class_name("WindowsForms10.msctls_progress32.app.0.141b42a_r9_ad1")
Unfortunately, I have no way of breaking this down into an XPath and using that instead. To the best of my knowledge, I don't know of a way to retrieve the XPath of an object using this address either. I'd like to find either a way to make to either.. (1) Insert this absolute/full address into expected_conditions.presence_of_element_located() or find an alternate way to confirm the object no longer exists.
- 20190502 UPDATE -
So far the closest I've come to a solution is combining the ideas below:
WebDriverWait(driver, 15).until(
expected_conditions.invisibility_of_element_located((eval("By.XPATH"), "//*[@name='MyApp']//*[@id='statusStrip1']//*[@class='WindowsForms10.msctls_progress32.app.0.141b42a_r9_ad1']"))
)
This does get me past confirming the Progress Bar has vanished so the test can continue. It also has the same timing issue as the wildcards mean the object has to be searched for first.
- 20190502 UPDATE (2) -
So, I had a bit of a breakthrough as to figuring out this puzzle. For using XPath, if I was doing Web UI testing, I can look at the XML code and see that it's a '//div', '//table', '//input', '//tspn', etc.. I've been using the UISpy tool to figure out the names of objects on my desktop application. As I was looking at it, I became curious about the labels in front of the object it's referencing.
From the Control View, I see 'MyApp' has the label 'Window' next to it. So I decided to use that to alter my XPath attempt to the following:
WebDriverWait(driver, 15).until(
expected_conditions.invisibility_of_element_located((eval("By.XPATH"), "//window[@name='MyApp']//*[@id='statusStrip1']//*[@class='WindowsForms10.msctls_progress32.app.0.141b42a_r9_ad1']"))
)
Not only did that work, but it was a tiny bit faster than the previous tries. The problem is the next layer is labeled as 'Status Bar' and I'm not really sure how to represent that in XPath.