[Autotest] Updating printer ui_utils flow.
Since R85.x the 'fit to width' item doesn't seem to remain on the screen
the entire time. This will change the second check (after a new printer
is selected) to look for other items instead.
BUG=chromium:1098025
TEST=re_run platform_printjob with and without change. With change
passed 20/20 times. Without failed often.
Change-Id: I69a3405717a445f6b5c6749ebf5bac840406fa4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2277102
Tested-by: Derek Beckett <dbeckett@chromium.org>
Reviewed-by: Kalin Stoyanov <kalin@chromium.org>
Commit-Queue: Derek Beckett <dbeckett@chromium.org>
Auto-Submit: Derek Beckett <dbeckett@chromium.org>
diff --git a/client/common_lib/ui_utils_helpers.py b/client/common_lib/ui_utils_helpers.py
index 15de46b..bba3733 100644
--- a/client/common_lib/ui_utils_helpers.py
+++ b/client/common_lib/ui_utils_helpers.py
@@ -2,6 +2,7 @@
from autotest_lib.client.common_lib import ui_utils
from autotest_lib.client.cros.input_playback import keyboard
import logging
+import time
class UIPrinterHelper(object):
@@ -25,11 +26,28 @@
self.open_printer_menu()
self.open_see_more_print_sub_menu()
self.select_printer_from_see_more_menu(printer_name)
- self.wait_for_print_ready()
+ if not self.check_print_window_open():
+ raise error.TestError("Print not open after setting printer.")
self.click_print(isPDF)
if self._keyboard:
self._keyboard.close()
+ def check_print_window_open(self):
+ """Check if the print window is still open."""
+ start_time = time.time()
+
+ # Giving up to 5 seconds for the window to load.
+ while time.time() - start_time < 5:
+ if (self.ui.item_present('Destination', role='inlineTextBox') and
+ self.ui.item_present('Cancel', role='button')) and not (
+ self.ui.item_present('Loading preview')):
+ return True
+
+ logging.info("Print Window was not open {}"
+ .format(self.ui.get_name_role_list()))
+ self.ui.screenshoter.take_ss()
+ return False
+
def open_printer_menu(self, retry=0):
"""Open the printer menu via the Chrome Dropdown."""
if not self._is_chrome_menu_open():