Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
install-chromedriver: true
if: matrix.os == 'windows-latest'
- uses: crystal-lang/install-crystal@v1
with:
Expand All @@ -58,7 +59,8 @@ jobs:
- uses: actions/checkout@v4
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: beta
chrome-version: stable
install-chromedriver: true
if: matrix.os == 'windows-latest'
- uses: crystal-lang/install-crystal@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crystallang/crystal:1.10.0
FROM crystallang/crystal:1.14.1
WORKDIR /data
EXPOSE 3002

Expand All @@ -7,7 +7,7 @@ RUN apt-get update \
libnss3 \
libgconf-2-4 \
chromium-browser \
firefox-geckodriver \
firefox \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY . /data
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
app:
build:
Expand Down
7 changes: 2 additions & 5 deletions script/setup
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
set -e
set -o pipefail

if command -v docker-compose > /dev/null; then
docker-compose build
docker-compose run app shards install
elif command -v docker compose > /dev/null; then
if command -v docker compose > /dev/null; then
docker compose build
docker compose run app shards install
else
printf 'Docker and/or docker-compose are not installed.\n'
printf 'Command docker compose does not exist. Install Docker.\n'
printf 'See https://docs.docker.com/compose/install/ for install instructions.\n'
exit 1
fi
Expand Down
4 changes: 1 addition & 3 deletions script/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
set -e
set -o pipefail

if command -v docker-compose > /dev/null; then
COMPOSE="docker-compose run app"
elif command -v docker compose > /dev/null; then
if command -v docker compose > /dev/null; then
COMPOSE="docker compose run app"
fi

Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
version: ">= 0.4.7, < 0.5"
webless:
github: crystal-loot/webless
version: ">= 0.1.0, < 0.2"
version: ">= 0.2.0, < 0.3"
html5:
github: naqvis/crystal-html5
version: ">= 0.5.0, < 0.6"
Expand Down
4 changes: 2 additions & 2 deletions spec/lucky_flow_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ private class FakeProcess
class_property command : String?
class_property shell : Bool?

def initialize(command, shell)
def initialize(command : String?, shell : Bool?)
@@command = command
@@shell = shell
end

def self.find_executable(string)
def self.find_executable(string : String)
"/fake_path_to_executable"
end
end
Expand Down
7 changes: 4 additions & 3 deletions spec/support/test_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class TestHandler
if context.request.resource == "/favicon.ico"
context.response.print ""
else
handler = routes[context.request.resource]
context.response.content_type = "text/html"
context.response.print handler.call(context)
if handler = routes[context.request.resource]?
context.response.content_type = "text/html"
context.response.print handler.call(context)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/ext/avram.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module AvramLuckyFlowHelpers
# ```
def fill_form(
form : Avram::SaveOperation.class | Avram::Operation.class,
**fields_and_values
**fields_and_values,
)
fields_and_values.each do |name, value|
element = field("#{form.param_key}:#{name}")
Expand Down
2 changes: 1 addition & 1 deletion src/lucky_flow.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LuckyFlow
driver.visit("#{settings.base_uri}#{path}")
end

def open_screenshot(process = Process, time = Time.utc, fullsize = false) : Void
def open_screenshot(process = Process, time = Time.utc, fullsize = false) : Nil
filename = generate_screenshot_filename(time)
take_screenshot(filename, fullsize)
process.new(command: "#{open_command(process)} #{filename}", shell: true)
Expand Down
2 changes: 1 addition & 1 deletion src/lucky_flow/error_message_when_not_found.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LuckyFlow::ErrorMessageWhenNotFound
@driver : LuckyFlow::Driver,
@selector : String,
@inner_text : String?,
@negate : Bool = false
@negate : Bool = false,
)
end

Expand Down
6 changes: 3 additions & 3 deletions src/lucky_flow/find_element.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LuckyFlow::FindElement
return matching_elements.first if matching_elements.first?

break unless has_retries_left?
sleep retry_delay_in_ms
sleep retry_delay_in_ms.milliseconds
end

raise_element_not_found_error
Expand All @@ -33,8 +33,8 @@ class LuckyFlow::FindElement
(settings.stop_retrying_after / settings.retry_delay).to_i
end

private def retry_delay_in_ms : Float
settings.retry_delay.total_milliseconds / 1_000
private def retry_delay_in_ms : Float64
settings.retry_delay.total_milliseconds
end

private def settings
Expand Down
6 changes: 3 additions & 3 deletions src/lucky_flow/selenium/driver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class LuckyFlow::Selenium::Driver < LuckyFlow::Driver
end

def screenshot(path : String)
FileUtils.mkdir_p(File.dirname(path))
Dir.mkdir_p(File.dirname(path))
session.screenshot(path)
end

Expand Down Expand Up @@ -89,7 +89,7 @@ abstract class LuckyFlow::Selenium::Driver < LuckyFlow::Driver

private def retry_start_session(e)
if Time.utc <= @retry_limit
sleep(0.1)
sleep(100.milliseconds)
start_session
else
raise e
Expand All @@ -98,7 +98,7 @@ abstract class LuckyFlow::Selenium::Driver < LuckyFlow::Driver

private def find_elements(
strategy : Symbol,
query : String
query : String,
) : Array(LuckyFlow::Element)
session.find_elements(strategy, query).map do |element|
LuckyFlow::Selenium::Element
Expand Down