So I am facing following issue. I am trying to get a report from a specific site(Its not public). The steps are open the webpage --> enter username --> goto nextPage --> enter Password --> Login(These are fine).
The next step is I have to click on a link text to go to the actual page where I can select dates to get the report. Now this is where i am facing issue.
After the button click, the site is prompting for the username and password with basic auth popup. Please see below code
import time
from selenium.webdriver import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdrivermon.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
userName='username'
passWord='password'
driver = webdriver.Edge()
wait = WebDriverWait(driver, 60)
driver.get('/')
driver.maximize_window()
userIn = wait.until(EC.visibility_of_element_located((By.ID,'input28')))
userIn.send_keys(userName)
nextBt = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'button-primary')))
nextBt.click()
passIn = wait.until(EC.visibility_of_element_located((By.ID,'input60')))
passIn.send_keys(passWord)
loginBt = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'button-primary')))
loginBt.click()
reportBt = wait.until(EC.element_to_be_clickable((By.ID,'LinkText')))
reportBt.click() #Error pointing out to this
print("Button Clicked") #Didnt Execute
alert = wait.until(EC.alert_is_present())
alert.send_keys(userName + Keys.TAB + passWord)
alert.accept()
time.sleep(60)
The script is throwing error in the reportBt.click()
. So no matter what I try I cant interact with the Pop-up.
So far I have tried.
- Using different browser.
- trying to use the URL directly like user:[email protected]
- Autoit
- The one above in the code.
Its just doesn't move pass the click command. print("Button Clicked")
was not executed in the above code.
Please see below error message.
C:\Users\redacted\.venv\Scripts\python.exe C:\Users\redacted\main.py
Traceback (most recent call last):
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 534, in _make_request
response = conn.getresponse()
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connection.py", line 516, in getresponse
httplib_response = super().getresponse()
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 1430, in getresponse
response.begin()
~~~~~~~~~~~~~~^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 331, in begin
version, status, reason = self._read_status()
~~~~~~~~~~~~~~~~~^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 292, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\socket.py", line 719, in readinto
return self._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\redacted\main.py", line 26, in <module>
reportBt.click()
~~~~~~~~~~~~~~^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 119, in click
self._execute(Command.CLICK_ELEMENT)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 570, in _execute
return self._parent.execute(command, params)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 427, in execute
response = selfmand_executor.execute(driver_command, params)
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 404, in execute
return self._request(command_info[0], url, body=data)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 428, in _request
response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\_request_methods.py", line 143, in request
return self.request_encode_body(
~~~~~~~~~~~~~~~~~~~~~~~~^
method, url, fields=fields, headers=headers, **urlopen_kw
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\_request_methods.py", line 278, in request_encode_body
return self.urlopen(method, url, **extra_kw)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
retries = retries.increment(
method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\util\util.py", line 39, in reraise
raise value
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
response = self._make_request(
conn,
...<10 lines>...
**response_kw,
)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 367, in _raise_timeout
raise ReadTimeoutError(
self, url, f"Read timed out. (read timeout={timeout_value})"
) from err
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=55044): Read timed out. (read timeout=120)
Process finished with exit code 1
Your help is greatly appreciated.
So I am facing following issue. I am trying to get a report from a specific site(Its not public). The steps are open the webpage --> enter username --> goto nextPage --> enter Password --> Login(These are fine).
The next step is I have to click on a link text to go to the actual page where I can select dates to get the report. Now this is where i am facing issue.
After the button click, the site is prompting for the username and password with basic auth popup. Please see below code
import time
from selenium.webdriver import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdrivermon.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
userName='username'
passWord='password'
driver = webdriver.Edge()
wait = WebDriverWait(driver, 60)
driver.get('https://example/')
driver.maximize_window()
userIn = wait.until(EC.visibility_of_element_located((By.ID,'input28')))
userIn.send_keys(userName)
nextBt = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'button-primary')))
nextBt.click()
passIn = wait.until(EC.visibility_of_element_located((By.ID,'input60')))
passIn.send_keys(passWord)
loginBt = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'button-primary')))
loginBt.click()
reportBt = wait.until(EC.element_to_be_clickable((By.ID,'LinkText')))
reportBt.click() #Error pointing out to this
print("Button Clicked") #Didnt Execute
alert = wait.until(EC.alert_is_present())
alert.send_keys(userName + Keys.TAB + passWord)
alert.accept()
time.sleep(60)
The script is throwing error in the reportBt.click()
. So no matter what I try I cant interact with the Pop-up.
So far I have tried.
- Using different browser.
- trying to use the URL directly like user:[email protected]
- Autoit
- The one above in the code.
Its just doesn't move pass the click command. print("Button Clicked")
was not executed in the above code.
Please see below error message.
C:\Users\redacted\.venv\Scripts\python.exe C:\Users\redacted\main.py
Traceback (most recent call last):
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 534, in _make_request
response = conn.getresponse()
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connection.py", line 516, in getresponse
httplib_response = super().getresponse()
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 1430, in getresponse
response.begin()
~~~~~~~~~~~~~~^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 331, in begin
version, status, reason = self._read_status()
~~~~~~~~~~~~~~~~~^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\http\client.py", line 292, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "C:\Users\redacted\AppData\Local\Programs\Python\Python313\Lib\socket.py", line 719, in readinto
return self._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\redacted\main.py", line 26, in <module>
reportBt.click()
~~~~~~~~~~~~~~^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 119, in click
self._execute(Command.CLICK_ELEMENT)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 570, in _execute
return self._parent.execute(command, params)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 427, in execute
response = selfmand_executor.execute(driver_command, params)
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 404, in execute
return self._request(command_info[0], url, body=data)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 428, in _request
response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\_request_methods.py", line 143, in request
return self.request_encode_body(
~~~~~~~~~~~~~~~~~~~~~~~~^
method, url, fields=fields, headers=headers, **urlopen_kw
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\_request_methods.py", line 278, in request_encode_body
return self.urlopen(method, url, **extra_kw)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
retries = retries.increment(
method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\util\util.py", line 39, in reraise
raise value
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
response = self._make_request(
conn,
...<10 lines>...
**response_kw,
)
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\redacted\.venv\Lib\site-packages\urllib3\connectionpool.py", line 367, in _raise_timeout
raise ReadTimeoutError(
self, url, f"Read timed out. (read timeout={timeout_value})"
) from err
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=55044): Read timed out. (read timeout=120)
Process finished with exit code 1
Your help is greatly appreciated.
Share Improve this question asked Feb 14 at 11:01 ArasanArasan 236 bronze badges1 Answer
Reset to default 0Let's take it a simple way. A basic auth pop-up is a window of OS, not a window of browser. You can control browser by using selenium
, but can not interact with a OS pop-up window. You can try other automation libary like win32gui
to interact with a OS pop-up.