我的脚本在Pycharm中运行得很慢



我最近开始使用带有selenium和Pycharm的Python作为编辑器。当我运行一个小脚本来填写电子邮件字段并单击"下一步"按钮时。执行这三个步骤花了将近25秒。不确定这些是否是为了更快地运行脚本而必须设置的任何设置。下面是我运行的脚本。

测试场景_包.py

import logging
import pytest
from PageUIObjectPackage.CreateAccountPages.EmailPage import CreateTxTAccountAddEmail
from PageUIObjectPackage.LoginPages.LoginPage import LoginToTxT
from UtilityPackage.CustomLoggerUtility import customLogger
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
TEST_INPUT_LIST = [("mgmwtest+22@gmail.com")]
@pytest.fixture(scope="module", autouse=True)
def module_header(request):
pytest.log = customLogger(logging.DEBUG)
pytest.log.info('Initializing web driver and test URL')
pytest.baseURL = "https://txt.texas.gov/sign-in?welcome=tdlr"
pytest.driver = webdriver.Chrome(ChromeDriverManager().install())
try:
pytest.driver.maximize_window()
pytest.log.info('Init Max window success')
except Exception as e:
pytest.log.error(e)
pytest.log.error('Init webdriver failed')
pytest.cal = LoginToTxT(pytest.driver)
pytest.cae = CreateTxTAccountAddEmail(pytest.driver)
def tear_down():
pytest.log.info('In tear down module, completed running test')
pytest.driver.quit()
request.addfinalizer(tear_down)
@pytest.mark.parametrize("email", TEST_INPUT_LIST)
def test_create_account_toas(email):
try:
pytest.driver.get(pytest.baseURL)
pytest.log.info('successfully opened the base URL')
except:
pytest.log.error('Exception when attempting to open the URL')
if email:
pytest.cal.clickCreateAccountButton()
pytest.cae.EnterEmail(email, email)
else:
pytest.log.error('email id or password is not provided')

登录页面.py

from UtilityPackage.CustomLoggerUtility import customLogger
from UtilityPackage.SeleniumDriverUtility import SeleniumDriver
import logging

class LoginToTxT(SeleniumDriver):
def __init__(self, driver):
super().__init__(driver)
self.driver = driver
self.log = customLogger(logging.DEBUG)
#Locators in TxT login page
_CreateAccountButton = "//button[text()='Create Account']"           #xpath
def clickCreateAccountButton(self):
self.elementClick(self._CreateAccountButton, locatorType="xpath")
def TakeScreenShot(self, resultMssage):
self.screenShot(resultMssage)

电子邮件页面.py

import time
from UtilityPackage.CustomLoggerUtility import customLogger
from UtilityPackage.SeleniumDriverUtility import SeleniumDriver
import logging
class CreateTxTAccountAddEmail(SeleniumDriver):
def __init__(self, driver):
super().__init__(driver)
self.driver = driver
self.log = customLogger(logging.DEBUG)
# Locators in TxT create account add email page
_EnterEmailField = "email"  # id
_ConfirmEmailField = "confirmEmail"  # id
def FillEmailField(self, email):
if email:
self.sendKeys(email, self._EnterEmailField, locatorType="id")
else:
self.log.error('email is not provided')
def FillConfirmEmailField(self, email):
if email:
self.sendKeys(email, self._ConfirmEmailField, locatorType="id")
else:
self.log.error('email is not provided')
def EnterEmail(self, email, confirmemail):
if email and confirmemail:
self.FillEmailField(email)
self.FillConfirmEmailField(confirmemail)
self.ClickNextButton(scrShtFileName="EmailPage_NextButtonClick")
time.sleep(3)
else:
self.log.error("Email is not provided")
def ClickNextButton(self, scrShtFileName):
self.elementClick(self._NextButton, locatorType="xpath")
self.TakeScreenShot(resultMssage=scrShtFileName)

请查看随附的视频,了解输入详细信息的速度有多慢样品运行

控制台输出

Testing started at 9:36 AM ...
"C:Texas.govAutomation ScriptPythonPython39python.exe" "C:Program FilesJetBrainsPyCharm Community Edition 2020.2.3pluginspython-cehelperspycharm_jb_pytest_runner.py" --path "C:/Texas.gov/Automation Script/TestPackage/sampletest.py"
Launching pytest with arguments C:/Texas.gov/Automation Script/TestPackage/sampletest.py in C:UsersTexas.govAutomation ScriptTestPackage
============================= test session starts =============================
platform win32 -- Python 3.9.0, pytest-6.1.1, py-1.9.0, pluggy-0.13.1 -- C:Texas.govAutomation ScriptPythonPython39python.exe
cachedir: .pytest_cache
rootdir: C:Texas.govAutomation ScriptTestPackage
collecting ... collected 1 item
sampletest.py::test_create_account_toas[mgmwtest+22@gmail.com] 
============================= 1 passed in 51.28s ==============================
Process finished with exit code 0

[WDM] - Current google-chrome version is 86.0.4240
[WDM] - Get LATEST driver version for 86.0.4240
[WDM] - Driver [C:.wdmdriverschromedriverwin3286.0.4240.22chromedriver.exe] found in cache
PASSED    [100%]  File "C:Program FilesJetBrainsPyCharm Community Edition 2020.2.3pluginspython-cehelperspycharm_jb_pytest_runner.py", line 43, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestconfig__init__.py", line 164, in main
ret = config.hook.pytest_cmdline_main(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 306, in pytest_cmdline_main
return wrap_session(config, _main)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 257, in wrap_session
session.exitstatus = doit(config, session) or 0
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 313, in _main
config.hook.pytest_runtestloop(session=session)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 338, in pytest_runtestloop
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 110, in pytest_runtest_protocol
runtestprotocol(item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 127, in runtestprotocol
reports.append(call_and_report(item, "call", log))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 216, in call_and_report
call = call_runtest_hook(item, when, **kwds)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 255, in call_runtest_hook
return CallInfo.from_call(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 310, in from_call
result = func()  # type: Optional[TResult]
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 256, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 163, in pytest_runtest_call
item.runtest()
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 1627, in runtest
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 184, in pytest_pyfunc_call
result = testfunction(**testargs)
File "C:Texas.govAutomation ScriptTestPackagesampletest.py", line 46, in test_create_account_toas
pytest.cal.clickCreateAccountButton()
File "C:Texas.govAutomation ScriptPageUIObjectPackageLoginPagesLoginPage.py", line 57, in clickCreateAccountButton
self.elementClick(self._CreateAccountButton, locatorType="xpath")
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 82, in elementClick
element = self.getElement(locator, locatorType)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 71, in getElement
self.waitForElement(locator, locatorType, timeout=2)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 149, in waitForElement
print_stack()
File "C:Program FilesJetBrainsPyCharm Community Edition 2020.2.3pluginspython-cehelperspycharm_jb_pytest_runner.py", line 43, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestconfig__init__.py", line 164, in main
ret = config.hook.pytest_cmdline_main(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 306, in pytest_cmdline_main
return wrap_session(config, _main)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 257, in wrap_session
session.exitstatus = doit(config, session) or 0
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 313, in _main
config.hook.pytest_runtestloop(session=session)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 338, in pytest_runtestloop
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 110, in pytest_runtest_protocol
runtestprotocol(item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 127, in runtestprotocol
reports.append(call_and_report(item, "call", log))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 216, in call_and_report
call = call_runtest_hook(item, when, **kwds)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 255, in call_runtest_hook
return CallInfo.from_call(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 310, in from_call
result = func()  # type: Optional[TResult]
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 256, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 163, in pytest_runtest_call
item.runtest()
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 1627, in runtest
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 184, in pytest_pyfunc_call
result = testfunction(**testargs)
File "C:Texas.govAutomation ScriptTestPackagesampletest.py", line 47, in test_create_account_toas
pytest.cae.EnterEmail(email, email)
File "C:Texas.govAutomation ScriptPageUIObjectPackageCreateAccountPagesEmailPage.py", line 41, in EnterEmail
self.FillEmailField(email)
File "C:Texas.govAutomation ScriptPageUIObjectPackageCreateAccountPagesEmailPage.py", line 24, in FillEmailField
self.sendKeys(email, self._EnterEmailField, locatorType="id")
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 93, in sendKeys
element = self.getElement(locator, locatorType)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 71, in getElement
self.waitForElement(locator, locatorType, timeout=2)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 149, in waitForElement
print_stack()
File "C:Program FilesJetBrainsPyCharm Community Edition 2020.2.3pluginspython-cehelperspycharm_jb_pytest_runner.py", line 43, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestconfig__init__.py", line 164, in main
ret = config.hook.pytest_cmdline_main(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 306, in pytest_cmdline_main
return wrap_session(config, _main)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 257, in wrap_session
session.exitstatus = doit(config, session) or 0
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 313, in _main
config.hook.pytest_runtestloop(session=session)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 338, in pytest_runtestloop
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 110, in pytest_runtest_protocol
runtestprotocol(item, nextitem=nextitem)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 127, in runtestprotocol
reports.append(call_and_report(item, "call", log))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 216, in call_and_report
call = call_runtest_hook(item, when, **kwds)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 255, in call_runtest_hook
return CallInfo.from_call(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 310, in from_call
result = func()  # type: Optional[TResult]
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 256, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestrunner.py", line 163, in pytest_runtest_call
item.runtest()
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 1627, in runtest
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestpython.py", line 184, in pytest_pyfunc_call
result = testfunction(**testargs)
File "C:Texas.govAutomation ScriptTestPackagesampletest.py", line 47, in test_create_account_toas
pytest.cae.EnterEmail(email, email)
File "C:Texas.govAutomation ScriptPageUIObjectPackageCreateAccountPagesEmailPage.py", line 42, in EnterEmail
self.FillConfirmEmailField(confirmemail)
File "C:Texas.govAutomation ScriptPageUIObjectPackageCreateAccountPagesEmailPage.py", line 32, in FillConfirmEmailField
self.sendKeys(email, self._ConfirmEmailField, locatorType="id")
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 93, in sendKeys
element = self.getElement(locator, locatorType)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 71, in getElement
self.waitForElement(locator, locatorType, timeout=2)
File "C:Texas.govAutomation ScriptUtilityPackageSeleniumDriverUtility.py", line 149, in waitForElement
print_stack()
File "C:Program FilesJetBrainsPyCharm Community Edition 2020.2.3pluginspython-cehelperspycharm_jb_pytest_runner.py", line 43, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestconfig__init__.py", line 164, in main
ret = config.hook.pytest_cmdline_main(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 306, in pytest_cmdline_main
return wrap_session(config, _main)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 257, in wrap_session
session.exitstatus = doit(config, session) or 0
File "C:Texas.govAutomation ScriptPythonPython39libsite-packages_pytestmain.py", line 313, in _main
config.hook.pytest_runtestloop(session=session)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggyhooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggymanager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "C:Texas.govAutomation ScriptPythonPython39libsite-packagespluggycallers.py", line 187, in _multicall
res = hook_impl.function(*args)

我发现了我行动迟缓的原因。在该项目中,它使用Seleniumdriverutility.py包,而在该方法中,WaitForElement没有返回元素,因此它正在等待完全超时。你知道它为什么不返回元素吗?

以下脚本来自Python 的Git Selenium驱动程序

def waitForElement(self, locator, locatorType="id",
timeout=10, pollFrequency=0.5):
element = None
try:
byType = self.getByType(locatorType)
print("Waiting for maximum :: " + str(timeout) +
" :: seconds for element to be clickable")
wait = WebDriverWait(self.driver, 10, poll_frequency=1,
ignored_exceptions=[NoSuchElementException,
ElementNotVisibleException,
ElementNotSelectableException])
element = wait.until(EC.element_to_be_clickable((byType,
"stopFilter_stops-0")))
print("Element appeared on the web page")
except:
print("Element not appeared on the web page")
print_stack()
return element

最新更新