0

I encounter this error when Webdriver manager is required to update any browsers used (Chrome, Firefox or Edge):

Launching pytest with arguments -m debug --html=reports/report.html --browser=edge --no-header --no-summary -q in C:\Users\Simon\PycharmProjects\XposCloud

test session starts ============================= collecting ... collected 8 items / 6 deselected / 2 selected

tests/stock_control_prerelease_regression_test.py::TestStockInPage::test_stock_in_menu Creating edge driver

INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\main.py", line 269, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\main.py", line 323, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\main.py", line 348, in pytest_runtestloop INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\runner.py", line 114, in pytest_runtest_protocol INTERNALERROR> runtestprotocol(item, nextitem=nextitem) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\runner.py", line 127, in runtestprotocol INTERNALERROR> rep = call_and_report(item, "setup", log) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages_pytest\runner.py", line 226, in call_and_report INTERNALERROR> hook.pytest_runtest_logreport(report=report) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\Simon\test-venv\Lib\site-packages\pluggy_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\pytest_plugin.py", line 306, in pytest_runtest_logreport INTERNALERROR> self.report_test_output(report, test_id) INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\pytest_plugin.py", line 208, in report_test_output INTERNALERROR> dump_test_stderr(self.teamcity, test_id, test_id, data) INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\common.py", line 78, in dump_test_stderr INTERNALERROR> messages.testStdErr(test_id, chunk, flowId=flow_id) INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 190, in testStdErr INTERNALERROR> self.message('testStdErr', name=testName, out=out, flowId=flowId) INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm_jb_runner_tools.py", line 117, in message INTERNALERROR> _old_service_messages.message(self, messageName, **properties) INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 101, in message INTERNALERROR> retry_on_EAGAIN(self.output.write)(self.encode(message)) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.1\plugins\python-ce\helpers\pycharm\teamcity\messages.py", line 68, in encode INTERNALERROR> value = value.encode(self.encoding) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> File "C:\Users\Simon\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 12, in encode INTERNALERROR> return codecs.charmap_encode(input,errors,encoding_table) INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNALERROR> UnicodeEncodeError: 'charmap' codec can't encode character '\u258e' in position 450: character maps to Closing edge driver

After the browser has been updated my tests function without this error.

I'm using this bit of code in conftest.py:

def driver(request):
    browser = request.config.getoption("--browser")
    # browser = request.param
    print(f"Creating {browser} driver")
    if browser == "chrome":
        my_driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    elif browser == "firefox":
        my_driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
    elif browser == "edge":
        my_driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()))
    else:
        raise TypeError(f"Expected 'chrome', 'firefox' or 'edge', but got {browser}")
    # my_driver.implicitly_wait(10)
    yield my_driver
    print(f"Closing {browser} driver")
    my_driver.quit()

I've tried to add encoding to the conftest.ini, like this:

def driver(request):
    browser = request.config.getoption("--browser")
    # browser = request.param
    browser.encode('ascii', 'ignore')
    print(f"Creating {browser} driver")
    if browser == "chrome":
        my_driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    elif browser == "firefox":
        my_driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
    elif browser == "edge":
        my_driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()))
    else:
        raise TypeError(f"Expected 'chrome', 'firefox' or 'edge', but got {browser}")
    # my_driver.implicitly_wait(10)
    yield my_driver
    print(f"Closing {browser} driver")
    my_driver.quit()

and this:

def driver(request):
    browser = request.config.getoption("--browser")
    # browser = request.param
    browser.encode('utf-8')
    print(f"Creating {browser} driver")
    if browser == "chrome":
        my_driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
    elif browser == "firefox":
        my_driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
    elif browser == "edge":
        my_driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()))
    else:
        raise TypeError(f"Expected 'chrome', 'firefox' or 'edge', but got {browser}")
    # my_driver.implicitly_wait(10)
    yield my_driver
    print(f"Closing {browser} driver")
    my_driver.quit()

but these both make no difference..

Am I adding encoding to the wrong bit of code?

Thanks in advance for any help offered.

0 Answers0