crystal-loot / selenium.cr

Selenium library for Crystal
https://crystal-loot.github.io/selenium.cr/
MIT License
24 stars 7 forks source link

Implement method to retrieve logs for Chrome #44

Closed mamantoha closed 5 days ago

mamantoha commented 5 months ago

Usage example:

require "../src/selenium"

service = Selenium::Service.chrome(driver_path: "/usr/bin/chromedriver")
driver = Selenium::Driver.for(:chrome, service: service)
capabilities = Selenium::Chrome::Capabilities.new
capabilities.chrome_options.args = ["no-sandbox", "headless", "disable-gpu"]
capabilities.logging_prefs = {"browser" => "ALL"}

session = driver.create_session(capabilities)

session.navigate_to("https://alerts.in.ua")

wait = Selenium::Helpers::Wait.new(timeout: 5.seconds, interval: 1.second)

# wait for console.log("loaded map") to be called
wait.until do
  session.log("browser").any? &.message.ends_with?("\"loaded map\"")
end

# ...
mamantoha commented 5 days ago

@jwoertink let me know if you need me to squash the commits into one.

jwoertink commented 5 days ago

It's fine. I'll squash them when I merge. That windows CI will probably just hang. I need to figure out why that's failing now, but that can come later. I think the rest of this looks good! :+1: Thanks for taking this on