-
Notifications
You must be signed in to change notification settings - Fork 7
[BUG]: Test setup throwing an exception "TypeError: string indices must be integers" #3
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When executing any test of the example python project in this repository, I am getting an exception "TypeError: string indices must be integers" on the test setup.
How to reproduce the issue
I am using Python 3.9, pytest 7.0.0 and selenium 4.1.0.
I navigate to the tests folder and then execute pytest using command: pytest .\test_markup.py
The test fails on ModuleNotFoundError: No module named 'src'
Then I tried to execute the same test using PyCharm Test Runner and got more detailed exception log, with "TypeError: string indices must be integers" when trying to create the remote webdriver. See the logs below.Logs appeared during using Healenium
TERMINAL LOG:
PS C:\Users\LucieLavickova\Git\healenium-example-python\tests> pytest .\test_markup.py
======================================================================= test session starts ========================================================================
platform win32 -- Python 3.9.7, pytest-7.0.0, pluggy-1.0.0
rootdir: C:\Users\LucieLavickova\Git\healenium-example-python\tests
collected 0 items / 1 error
============================================================================== ERRORS ==============================================================================
_________________________________________________________________ ERROR collecting test_markup.py __________________________________________________________________
ImportError while importing test module 'C:\Users\LucieLavickova\Git\healenium-example-python\tests\test_markup.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
..\..\..\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_markup.py:1: in <module>
from src.main.pages.markup_page import *
E ModuleNotFoundError: No module named 'src'
===================================================================== short test summary info ======================================================================
ERROR test_markup.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================= 1 error in 0.14s =========================================================================
PYCHARM TEST RUNNER LOG:
C:\Users\LucieLavickova\Git\healenium-example-python\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.1\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --target test_markup.py::Test_Markup.test_button_click_specific_find_element
Testing started at 12:40 ...
Launching pytest with arguments test_markup.py::Test_Markup::test_button_click_specific_find_element --no-header --no-summary -q in C:\Users\LucieLavickova\Git\healenium-example-python\tests
============================= test session starts =============================
collecting ... collected 1 item
test_markup.py::Test_Markup::test_button_click_specific_find_element ERROR [100%]
test setup failed
self = <test_markup.Test_Markup object at 0x000001D8EDDF97C0>
@pytest.fixture()
def setup_method(self):
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
> self.driver = webdriver.Remote(
command_executor="http://localhost:8085",
desired_capabilities=webdriver.DesiredCapabilities.CHROME,
options=options)
test_base.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py:268: in __init__
self.start_session(capabilities, browser_profile)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.remote.webdriver.WebDriver (session="None")>
capabilities = {'browserName': 'chrome', 'goog:chromeOptions': {'args': ['--no-sandbox'], 'extensions': []}, 'pageLoadStrategy': 'normal'}
browser_profile = None
def start_session(self, capabilities: dict, browser_profile=None) -> None:
"""
Creates a new session with the desired capabilities.
:Args:
- capabilities - a capabilities dict to start the session with.
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested.
"""
if not isinstance(capabilities, dict):
raise InvalidArgumentException("Capabilities must be a dictionary")
if browser_profile:
if "moz:firefoxOptions" in capabilities:
capabilities["moz:firefoxOptions"]["profile"] = browser_profile.encoded
else:
capabilities.update({'firefox_profile': browser_profile.encoded})
w3c_caps = _make_w3c_caps(capabilities)
parameters = {"capabilities": w3c_caps,
"desiredCapabilities": capabilities}
response = self.execute(Command.NEW_SESSION, parameters)
if 'sessionId' not in response:
response = response['value']
> self.session_id = response['sessionId']
E TypeError: string indices must be integers
..\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py:362: TypeError
test_markup.py:7 (Test_Markup.test_button_click_specific_find_element)
self = <test_markup.Test_Markup object at 0x000001D8EDDF97C0>
method = <bound method Test_Markup.test_button_click_specific_find_element of <test_markup.Test_Markup object at 0x000001D8EDDF97C0>>
def teardown_method(self, method):
> self.driver.quit()
E AttributeError: 'Test_Markup' object has no attribute 'driver'
test_base.py:23: AttributeError
test_markup.py::Test_Markup::test_button_click_specific_find_element ERROR [100%]
======================== 1 warning, 2 errors in 10.39s ========================
Process finished with exit code 1Expected behavior
Test should pass
Actual behavior
Test failed on error
Healenium Proxy version
0.2.1
Healenium Backend version
3.2.0
Selenium version
4.1.0
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working