Unable to expand selenium WebElement object (/ access its properties) in PyCharm while debugging selenium test

我只是一个虾纸丫 提交于 2019-12-11 15:08:41

问题


I am trying to access value 12345 from span element on a target webpage which looks like this:

<span id="[long-dynamically-generated-unique-id]:StaticFixedString"> 12345</span>

[long-dynamically-generated-unique-id] is unique id which changes every time I visits the website. So I want to base my selector on :StaticFixedString. I am able to do this as follows:

amt = driver.find_element_by_xpath(u"//*[contains(@id, 'StaticFixedString')]")

At least, in debug mode, I am able to see amt in Variables window of PyCharm as follows:

When I click on triangular arrow in front of the variable to expand its properties, the taskbar icon of chrome window opened by selenium starts flashing. Variable window of PyCharm shows Collecting data... as follows:

After some time, it shows something like this:

It then logged following error:

Traceback (most recent call last):
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
    raise err
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\User\Program Files\python\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\User\Program Files\python\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\User\Program Files\python\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\User\Program Files\python\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "C:\User\Program Files\python\lib\http\client.py", line 956, in send
    self.connect()
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connection.py", line 183, in connect
    conn = self._new_conn()
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x05505050>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1508, in do_it
    var_obj = pydevd_vars.getVariable(self.thread_id, self.frame_id, scope, attrs)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_vars.py", line 232, in getVariable
    var = resolver.resolve(var, k)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydevd_bundle\pydevd_resolver.py", line 82, in resolve
    return getattr(var, attribute)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 505, in location_once_scrolled_into_view
    'args': [self]})['value']
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
    resp = self._conn.request(method, url, body=body, headers=headers)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\request.py", line 72, in request
    **urlopen_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\request.py", line 150, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\poolmanager.py", line 326, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    **response_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    **response_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    **response_kw)
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\User\workspaces\pyworkspaces\fin2\venv\lib\site-packages\urllib3\util\retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=58748): Max retries exceeded with url: /session/f4932e6b7b8eba0a50867e4c73bc9a35/execute/sync (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x05505050>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

Why is this happening? What I am missing?

Edit

The target size has right click disabled. Can this be an issue?

来源:https://stackoverflow.com/questions/56685757/unable-to-expand-selenium-webelement-object-access-its-properties-in-pycharm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!