from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
chrome_options = Options()
chrome_options.add_argument("--enable-logging")
chrome_options.add_argument("--v=1")
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.set_capability('goog:loggingPrefs', {'browser': 'ALL'})
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://example.com/')
time.sleep(7)
driver.execute_script("console.log('hello there')")
logs = driver.get_log('browser')
while True:
pass``` so its not sending anything to console other than errors ```[17876:18356:0717/071059.716:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -100
[17876:18356:0717/071059.720:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -100
[17876:18356:0717/071109.476:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -100
[8076:4424:0717/071110.838:ERROR:device_event_log_impl.cc(196)] [07:11:10.838] USB: usb_service_win.cc:105 SetupDiGetDeviceProperty({{A45C254E-DF1C-4EFD-8020-67D146A850E0}, 6}) failed: Element not found. (0x490)
Created TensorFlow Lite XNNPACK delegate for CPU.
[17876:18356:0717/071122.804:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -100```
#๐ return js code output in browser console?
13 messages ยท Page 1 of 1 (latest)
@marsh epoch
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
how can i make it return the message i logged to console?
maybe console_log = driver.exe..
it just said None in python console
[25256:12988:0717/072931.584:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -107
[25256:12988:0717/072941.053:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -100
[28204:29568:0717/072945.176:ERROR:device_event_log_impl.cc(196)] [07:29:45.176] USB: usb_service_win.cc:105 SetupDiGetDeviceProperty({{A45C254E-DF1C-4EFD-8020-67D146A850E0}, 6}) failed: Element not found. (0x490)
[25256:12988:0717/072949.620:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -107
None
Created TensorFlow Lite XNNPACK delegate for CPU.```
??
Try replacing the loop at the bottom with:
while True:
for log in driver.get_log('browser'):
print('LOG:', log)
time.sleep(1)
It could be that you're calling get_log too quickly. If execute_script is async, it may run after you get the logs.
oh that worked ty
Odd, because execute_script is actually syncronous. Oh well. Glad it's working now.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.