-
Notifications
You must be signed in to change notification settings - Fork 0
Add responsive capture , cross origin iframe capture and percy on automate session #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bb71ece
Added rresponsive capture feature and poa
yashmahamulkar-bs 0155291
Adding Cross IFrame and Responsive Capture feature
yashmahamulkar-bs 4e85907
fixes
yashmahamulkar-bs 3868cdd
fix
yashmahamulkar-bs dfc6714
added spec
yashmahamulkar-bs 2a4d197
removing widht from health record
yashmahamulkar-bs 782de1b
fixes
yashmahamulkar-bs c7f0df0
removing height inner - outer
yashmahamulkar-bs b939015
Fix
yashmahamulkar-bs f5539e4
fixed lint
yashmahamulkar-bs 6684578
Fix snapshot response parsing, typo in constant name, and nil target_…
yashmahamulkar-bs abf6863
fix
yashmahamulkar-bs 223a104
Fixes
yashmahamulkar-bs 356c57f
enabling resonsive capture sleep env
yashmahamulkar-bs 3ec1c8e
removing unnecessary comments
yashmahamulkar-bs 91db97f
blank commit:
yashmahamulkar-bs 8d98585
blank commit:
yashmahamulkar-bs d394120
lint fix
yashmahamulkar-bs ce0daea
fix: address code review issues for thread safety, option mutation, a…
yashmahamulkar-bs 7922c2d
removing comments
yashmahamulkar-bs cf4f40d
Resolving review
yashmahamulkar-bs 3eae801
alpha version release
yashmahamulkar-bs 437fc21
removing version form main pr
yashmahamulkar-bs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| class Cache | ||
| CACHE = {} # rubocop:disable Style/MutableConstant | ||
| CACHE_TIMEOUT = 5 * 60 # 300 seconds | ||
| TIMEOUT_KEY = 'last_access_time'.freeze | ||
| MUTEX = Mutex.new | ||
|
|
||
| # Caching Keys | ||
| CAPABILITIES = 'capabilities'.freeze | ||
| COMMAND_EXECUTOR_URL = 'command_executor_url'.freeze | ||
|
|
||
| def self.check_types(session_id, property) | ||
| raise TypeError, 'Argument session_id should be string' unless session_id.is_a?(String) | ||
| raise TypeError, 'Argument property should be string' unless property.is_a?(String) | ||
| end | ||
|
|
||
| def self.set_cache(session_id, property, value) | ||
| check_types(session_id, property) | ||
| MUTEX.synchronize do | ||
| session = CACHE[session_id] || {} | ||
| session[TIMEOUT_KEY] = Time.now.to_f | ||
| session[property] = value | ||
| CACHE[session_id] = session | ||
| end | ||
| end | ||
|
|
||
| def self.get_cache(session_id, property) | ||
| check_types(session_id, property) | ||
| MUTEX.synchronize do | ||
| cleanup_cache | ||
| session = CACHE[session_id] || {} | ||
| session[property] | ||
| end | ||
| end | ||
|
|
||
| def self.clear_cache! | ||
| MUTEX.synchronize do | ||
| CACHE.clear | ||
| end | ||
| end | ||
|
|
||
| def self.cleanup_cache | ||
| now = Time.now.to_f | ||
| CACHE.delete_if do |_, session| | ||
| timestamp = session[TIMEOUT_KEY] | ||
| timestamp && (now - timestamp >= CACHE_TIMEOUT) | ||
| end | ||
| end | ||
| private_class_method :cleanup_cache | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| require_relative 'cache' | ||
|
|
||
| class DriverMetaData | ||
| def initialize(driver) | ||
| @driver = driver | ||
| end | ||
|
|
||
| def session_id | ||
| @driver.session_id | ||
| end | ||
|
|
||
| def command_executor_url | ||
| cached = Cache.get_cache(session_id, Cache::COMMAND_EXECUTOR_URL) | ||
| return cached unless cached.nil? | ||
|
|
||
| url = nil | ||
| begin | ||
| raw = @driver.send(:bridge).http.send(:server_url) | ||
| url = raw.to_s unless raw.nil? | ||
| rescue StandardError => e | ||
| if defined?(Percy) | ||
| Percy.log("Could not get command_executor_url via bridge.http.server_url: #{e}", 'debug') | ||
| end | ||
| end | ||
|
|
||
| if url.nil? || url.empty? | ||
| begin | ||
| raw = @driver.send(:bridge).http.instance_variable_get(:@server_url) | ||
| url = raw.to_s unless raw.nil? | ||
| rescue StandardError => e | ||
| Percy.log("Could not get @server_url instance variable: #{e}", 'debug') if defined?(Percy) | ||
| end | ||
| end | ||
|
|
||
| url ||= '' | ||
| Cache.set_cache(session_id, Cache::COMMAND_EXECUTOR_URL, url) | ||
| url | ||
| end | ||
|
|
||
| def capabilities | ||
| cached = Cache.get_cache(session_id, Cache::CAPABILITIES) | ||
| return cached unless cached.nil? | ||
|
|
||
| caps = begin | ||
| @driver.capabilities.as_json | ||
| rescue StandardError | ||
| begin | ||
| @driver.capabilities.to_h | ||
| rescue StandardError | ||
| {} | ||
| end | ||
| end | ||
|
|
||
| Cache.set_cache(session_id, Cache::CAPABILITIES, caps) | ||
| caps | ||
| end | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.