wasm tests: Fix manual Selenium tests

Manual tests using Selenium for browser automation were not properly
updated when we introduced changes to our DOM structure.
Update the testing framework so elements in shadow root may be
properly accessed.

Change-Id: I45f7d63a833bc48a3b68016ef937e56425bdff87
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Piotr Wierciński 2023-11-03 09:54:30 +01:00
parent 597de2b1dc
commit 105a8d90bc
2 changed files with 12 additions and 5 deletions

View File

@ -545,10 +545,15 @@ class Screen:
.startswith('qt-window-'), self.hit_test_point(x, y))]]
def query_windows(self):
shadow_container = self.element.find_element(By.CSS_SELECTOR, f'#qt-shadow-container')
return [
Window(self, element=element) for element in self.element.shadow_root.find_elements(
Window(self, element=element) for element in shadow_container.shadow_root.find_elements(
By.CSS_SELECTOR, f'div#{self.name} > div.qt-window')]
def find_element(self, method, query):
shadow_container = self.element.find_element(By.CSS_SELECTOR, f'#qt-shadow-container')
return shadow_container.shadow_root.find_element(method, query)
class Window:
def __init__(self, parent=None, rect=None, title=None, element=None, visible=True):
@ -556,7 +561,7 @@ class Window:
if element is not None:
self.element = element
self.title = element.find_element(
By.CSS_SELECTOR, f'.title-bar > .window-name').text
By.CSS_SELECTOR, f'.title-bar > .window-name').get_property("textContent")
information = self.__window_information()
self.screen = Screen(self.driver, screen_name=information['screen']['name'])
pass
@ -578,8 +583,8 @@ class Window:
)
self.screen = parent
self._window_id = self.__window_information()['id']
self.element = self.screen.element.shadow_root.find_element(
By.CSS_SELECTOR, f'#qt-window-{self._window_id}')
self.element = self.screen.find_element(
By.CSS_SELECTOR, f'#qt-window-{self._window_id}')
if visible:
self.set_visible(True)

View File

@ -67,7 +67,9 @@
events: () => eventList,
hitTestPoint: (x, y, screenId) => {
return document
.querySelector(`#${screenId}`).shadowRoot.elementsFromPoint(x, y);
.querySelector(`#${screenId}`)
.querySelector('#qt-shadow-container')
.shadowRoot.elementsFromPoint(x, y);
}
};
})();