Closed p0deje closed 2 weeks ago
Yeah, this isn't really testing the code, just showing how to use it, so maybe we don't need it in specs, just in our docs. What does this look like in the python?
driver.navigate.to url_for('bidi/logEntryAdded.html')
log_entries = []
driver.script.add_console_message_handler { |log| log_entries << log if log.level == 'error'}
driver.find_element(id: 'consoleLog').click
driver.find_element(id: 'consoleError').click
wait.until { log_entries.any? }
expect(log_entries[0].level).to eq('error')
Yeah, this isn't really testing the code, just showing how to use it, so maybe we don't need it in specs, just in our docs. What does this look like in the python?
driver.navigate.to url_for('bidi/logEntryAdded.html') log_entries = [] driver.script.add_console_message_handler { |log| log_entries << log if log.level == 'error'} driver.find_element(id: 'consoleLog').click driver.find_element(id: 'consoleError').click wait.until { log_entries.any? } expect(log_entries[0].level).to eq('error')
The equivalent would one of:
# simple lambda
errors = []
driver.script.add_console_message_handler(lambda log_entry: if log.level == 'error': errors.append(log_entry) }
# function
self.errors = []
def collect_error(log_entry)
if log_entry.level == 'error':
self.errors.append(log_entry)
driver.script.add_console_message_handler(collect_error}
# aggregator object
class ErrorsHandler:
def __init__():
self.errors = []
def collect_error(log_entry)
if log_entry.level == 'error':
self.errors.append(log_entry)
errors_handler = ErrorsHandler()
driver.script.add_console_message_handler(errors_handler.collect_error}
@p0deje I didn't realize you added the options in here. I implemented enable_bidi()
and web_socket_url
parameters in trunk. You want me to rebase this?
**Action:** Python / Lint |
**Failed stage:** [Test with tox](https://github.com/SeleniumHQ/selenium/actions/runs/9571783856/job/26389959727) [❌] |
**Failure summary:**
The action failed because the code formatting check detected that the file conftest.py is not properly formatted according to the black code style.1 file would be reformatted : This indicates that conftest.py does not comply with the required code style. |
Relevant error logs:```yaml 1: ##[group]Operating System 2: Ubuntu ... 223: + 224: request.addfinalizer(fin) 225: if request.node.get_closest_marker("no_driver_after_test"): 226: driver_instance = None 227: would reformat conftest.py 228: Oh no! 💥 💔 💥 229: 1 file would be reformatted, 219 files would be left unchanged. 230: linting-ci: exit 1 (1.83 seconds) /home/runner/work/selenium/selenium/py> black --check --diff selenium/ test/ conftest.py -l 120 pid=1949 231: linting-ci: FAIL code 1 (5.66=setup[3.37]+cmd[0.46,1.83] seconds) 232: evaluation failed :( (5.82 seconds) 233: ##[error]Process completed with exit code 1. ``` |
Attention: Patch coverage is 18.89764%
with 103 lines
in your changes missing coverage. Please review.
Project coverage is 56.98%. Comparing base (
5c5487f
) to head (d07cbe3
). Report is 3 commits behind head on trunk.:exclamation: Current head d07cbe3 differs from pull request most recent head 43c5fc9
Please upload reports for the commit 43c5fc9 to get more accurate results.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Partial Python implementation of https://github.com/SeleniumHQ/selenium/issues/13992, closely mimics Ruby part from https://github.com/SeleniumHQ/selenium/pull/14073