Refactor seleniumbase imports
This commit is contained in:
parent
e8be9f696e
commit
610a92d0c0
|
@ -1,11 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import codecs
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
from seleniumbase.config import settings
|
||||
|
||||
|
||||
|
@ -29,6 +27,7 @@ def log_screenshot(test_logpath, driver, screenshot=None, get=False):
|
|||
|
||||
def get_master_time():
|
||||
""" Returns (timestamp, the_date, the_time) """
|
||||
import datetime
|
||||
timestamp = str(int(time.time())) + " (Unix Timestamp)"
|
||||
now = datetime.datetime.now()
|
||||
utc_offset = -time.timezone / 3600.0
|
||||
|
@ -61,6 +60,7 @@ def get_master_time():
|
|||
|
||||
|
||||
def log_test_failure_data(test, test_logpath, driver, browser, url=None):
|
||||
import traceback
|
||||
basic_info_name = settings.BASIC_INFO_NAME
|
||||
basic_file_path = "%s/%s" % (test_logpath, basic_info_name)
|
||||
log_file = codecs.open(basic_file_path, "w+", "utf-8")
|
||||
|
|
|
@ -25,7 +25,6 @@ Code becomes greatly simplified and easier to maintain.
|
|||
import codecs
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
@ -43,7 +42,6 @@ from seleniumbase import config as sb_config
|
|||
from seleniumbase.common import decorators
|
||||
from seleniumbase.config import settings
|
||||
from seleniumbase.core import log_helper
|
||||
from seleniumbase.core import tour_helper
|
||||
from seleniumbase.fixtures import constants
|
||||
from seleniumbase.fixtures import css_to_xpath
|
||||
from seleniumbase.fixtures import js_utils
|
||||
|
@ -5491,6 +5489,8 @@ class BaseCase(unittest.TestCase):
|
|||
interval - The delay time between autoplaying tour steps. (Seconds)
|
||||
If set to 0 (default), the tour is fully manual control.
|
||||
"""
|
||||
from seleniumbase.core import tour_helper
|
||||
|
||||
if self.headless:
|
||||
return # Tours should not run in headless mode.
|
||||
|
||||
|
@ -5542,6 +5542,7 @@ class BaseCase(unittest.TestCase):
|
|||
save the tour to.
|
||||
url - The URL where the tour starts. If not specified, the URL
|
||||
of the current page will be used. """
|
||||
from seleniumbase.core import tour_helper
|
||||
if not url:
|
||||
url = self.get_current_url()
|
||||
tour_helper.export_tour(
|
||||
|
@ -6470,6 +6471,7 @@ class BaseCase(unittest.TestCase):
|
|||
|
||||
def __get_new_timeout(self, timeout):
|
||||
""" When using --timeout_multiplier=#.# """
|
||||
import math
|
||||
self.__check_scope()
|
||||
try:
|
||||
timeout_multiplier = float(self.timeout_multiplier)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
"""
|
||||
Convert CSS selectors into XPath selectors
|
||||
"""
|
||||
|
||||
from cssselect.xpath import GenericTranslator, is_non_whitespace
|
||||
from cssselect.xpath import GenericTranslator
|
||||
|
||||
|
||||
class ConvertibleToCssTranslator(GenericTranslator):
|
||||
|
@ -20,6 +19,7 @@ class ConvertibleToCssTranslator(GenericTranslator):
|
|||
return xpath
|
||||
|
||||
def xpath_attrib_includes(self, xpath, name, value):
|
||||
from cssselect.xpath import is_non_whitespace
|
||||
if is_non_whitespace(value):
|
||||
xpath.add_condition(
|
||||
"contains(%s, %s)"
|
||||
|
|
|
@ -33,8 +33,6 @@ from selenium.webdriver.remote.errorhandler import NoAlertPresentException
|
|||
from selenium.webdriver.remote.errorhandler import NoSuchFrameException
|
||||
from selenium.webdriver.remote.errorhandler import NoSuchWindowException
|
||||
from seleniumbase.config import settings
|
||||
from seleniumbase.core import log_helper
|
||||
from seleniumbase.fixtures import page_utils
|
||||
from seleniumbase.fixtures import shared_utils as s_utils
|
||||
ENI_Exception = selenium_exceptions.ElementNotInteractableException
|
||||
|
||||
|
@ -598,6 +596,7 @@ def save_page_source(driver, name, folder=None):
|
|||
name - The file name to save the current page's HTML to.
|
||||
folder - The folder to save the file to. (Default = current folder)
|
||||
"""
|
||||
from seleniumbase.core import log_helper
|
||||
if not name.endswith(".html"):
|
||||
name = name + ".html"
|
||||
if folder:
|
||||
|
@ -716,6 +715,7 @@ def switch_to_frame(driver, frame, timeout=settings.SMALL_TIMEOUT):
|
|||
frame - the frame element, name, id, index, or selector
|
||||
timeout - the time to wait for the alert in seconds
|
||||
"""
|
||||
from seleniumbase.fixtures import page_utils
|
||||
start_ms = time.time() * 1000.0
|
||||
stop_ms = start_ms + (timeout * 1000.0)
|
||||
for x in range(int(timeout * 10)):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""
|
||||
Convert XPath selectors into CSS selectors
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
_sub_regexes = {
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
import sys
|
||||
import time
|
||||
from nose.plugins import Plugin
|
||||
from nose.exc import SkipTest
|
||||
from seleniumbase.config import settings
|
||||
from seleniumbase.core import download_helper
|
||||
from seleniumbase.core import log_helper
|
||||
from seleniumbase.core import report_helper
|
||||
from seleniumbase.fixtures import constants, errors
|
||||
from seleniumbase.fixtures import constants
|
||||
|
||||
|
||||
class Base(Plugin):
|
||||
|
@ -227,6 +226,7 @@ class Base(Plugin):
|
|||
error states, we want to make sure that they don't show up in
|
||||
the nose output as errors.
|
||||
"""
|
||||
from seleniumbase.fixtures import errors
|
||||
if (err[0] == errors.BlockedTest or (
|
||||
err[0] == errors.SkipTest) or (
|
||||
err[0] == errors.DeprecatedTest)):
|
||||
|
@ -243,6 +243,8 @@ class Base(Plugin):
|
|||
If the database plugin is not present, we have to handle capturing
|
||||
"errors" that shouldn't be reported as such in base.
|
||||
"""
|
||||
from nose.exc import SkipTest
|
||||
from seleniumbase.fixtures import errors
|
||||
if not hasattr(test.test, "testcase_guid"):
|
||||
if err[0] == errors.BlockedTest:
|
||||
raise SkipTest(err[1])
|
||||
|
|
Loading…
Reference in New Issue