Comments (4)
sleep(@browser.slowmo) if slowmoable && @browser.slowmo > 0
Is this part of addressing this?
Was thinking of just doing a sleep on slowmo define time, we can just do an interval loop to wait on a specific element on the page to show.
Because of this sleep, my current test run seems to take too long to complete.
from ferrum.
This is my hacky attempt in my own spec_helper.rb. Rather than just using slowmo.
def wait_for(css_element, visibility: :all)
@staled_retries ||= 120
element = first(css_element, visible: visibility, wait: 0.3)
warn_log "Found #{css_element}"
yield(element) if block_given?
element
rescue Capybara::ElementNotFound, Capybara::ExpectationNotMet => e
warn_log "#{css_element} stale for: #{@staled_retries}"
if @staled_retries.zero?
page_path = save_page
screenshot_path = save_screenshot
debug_log "Page at #{page_path}"
debug_log "Screenshot at #{screenshot_path}"
raise e
else
@staled_retries -= 1
sleep(0.2)
retry
end
end
from ferrum.
I've been using this... seems like something like this should be in Ferrum.
module Ferrum
class Frame
module DOM
#
# Finds a node using XPath or a CSS path selector, with waiting.
#
# @param [String] selector
# The XPath or CSS path selector.
#
# @param [Integer] init
# How long we should wait before starting to look.
#
# @param [Integer] wait
# How long we should wait for node to appear.
#
# @param [Integer] step
# How long to wait between checking.
#
# @return [Node, nil]
# The matching node.
#
# @example
# browser.with("a[aria-label='CA']", init:1, wait:5, step:0.2) # => Node
#
def with(selector, init:nil, wait:1, step:0.1)
sleep(init) if init
meth = selector.start_with?("/") ? :at_xpath : :at_css
until node = send(meth, selector) rescue nil
(wait -= step) > 0 ? sleep(step) : break
end
node
end
end
end
end
I use it like this:
site.with("#iux-identifier-user-id", init: 2, wait:8, step: 0.5).focus.type(user)
from ferrum.
This is quite a bit simpler than #236, granted this one is just pure Ruby version and doesn't use js timeouts, etc.
from ferrum.
Related Issues (20)
- Errno::ECONNREFUSED on browser initialization HOT 3
- Headless new gives Ferrum::NoSuchPageError on screenshot HOT 2
- consider using === in network blacklist matching
- Doesn't work on ruby 3.2 HOT 1
- Saving via browser.mhtml and via cmd+S differs a lot on Youtube HOT 3
- Network.loadingFailed error preventing file from downloading HOT 13
- Conditionally Render Page header and footer template HOT 2
- browser.quit doesn't close session HOT 6
- Include type and stackTrace in logging for console API
- `wait_for_network_idle` failing due to pending requests on previous page HOT 1
- Remove `disable-gpu`default flag for Apple Silicon HOT 3
- authenticate current_user in ferrum browser
- Hang/Timeout in dialog HOT 9
- Ferrum::PendingConnectionsError - what to do?
- Browserless 2.0 support HOT 12
- Permission denied when using Firefox HOT 1
- warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
- How to add images for PDF ?
- I am getting syntax error after installing ferrum. Am i missing something here HOT 4
- What is the purpose of navigation awaiting in `Page.command` method? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ferrum.