Navigates the current browser window to the specified page.
(self, url, **kwargs)
| 227 | ) |
| 228 | |
| 229 | def open(self, url, **kwargs): |
| 230 | """Navigates the current browser window to the specified page.""" |
| 231 | self.__check_scope() |
| 232 | if self.__is_cdp_swap_needed(): |
| 233 | self.cdp.open(url, **kwargs) |
| 234 | return |
| 235 | elif ( |
| 236 | getattr(self.driver, "_is_using_uc", None) |
| 237 | # and getattr(self.driver, "_is_using_auth", None) |
| 238 | and not getattr(self.driver, "_is_using_cdp", None) |
| 239 | ): |
| 240 | # Auth in UC Mode requires CDP Mode |
| 241 | # (and now we're always forcing it) |
| 242 | logging.info("open() in UC Mode now always activates CDP Mode.") |
| 243 | self.activate_cdp_mode(url, **kwargs) |
| 244 | return |
| 245 | elif ( |
| 246 | getattr(self.driver, "_is_using_uc", None) |
| 247 | and getattr(self.driver, "_is_using_cdp", None) |
| 248 | ): |
| 249 | self.disconnect() |
| 250 | self.cdp.open(url, **kwargs) |
| 251 | return |
| 252 | self._check_browser() |
| 253 | if self.__needs_minimum_wait(): |
| 254 | time.sleep(0.04) |
| 255 | pre_action_url = None |
| 256 | with suppress(Exception): |
| 257 | pre_action_url = self.driver.current_url |
| 258 | url = str(url).strip() # Remove leading and trailing whitespace |
| 259 | if not self.__looks_like_a_page_url(url): |
| 260 | # url should start with one of the following: |
| 261 | # "http:", "https:", "://", "data:", "file:", |
| 262 | # "about:", "chrome:", or "edge:". |
| 263 | if page_utils.is_valid_url("https://" + url): |
| 264 | url = "https://" + url |
| 265 | else: |
| 266 | raise Exception('Invalid URL: "%s"!' % url) |
| 267 | self.__last_page_load_url = None |
| 268 | js_utils.clear_out_console_logs(self.driver) |
| 269 | if url.startswith("://"): |
| 270 | # Convert URLs such as "://google.com" into "https://google.com" |
| 271 | url = "https" + url |
| 272 | if self.recorder_mode and not self.__dont_record_open: |
| 273 | time_stamp = self.execute_script("return Date.now();") |
| 274 | origin = self.get_origin() |
| 275 | action = ["o_url", origin, url, str(int(time_stamp) - 1)] |
| 276 | self.__extra_actions.append(action) |
| 277 | action = ["_url_", origin, url, time_stamp] |
| 278 | self.__extra_actions.append(action) |
| 279 | if self.recorder_mode and self.__new_window_on_rec_open: |
| 280 | c_url = self.driver.current_url |
| 281 | if ("http:") in c_url or ("https:") in c_url or ("file:") in c_url: |
| 282 | if self.get_domain_url(url) != self.get_domain_url(c_url): |
| 283 | self.open_new_window(switch_to=True) |
| 284 | try: |
| 285 | self.driver.get(url) |
| 286 | except Exception as e: |
no test coverage detected