Class: Applitools::Selenium::DomSnapshotScript::DomSnapshotScript
- Inherits:
-
Object
- Object
- Applitools::Selenium::DomSnapshotScript::DomSnapshotScript
- Defined in:
- lib/applitools/selenium/visual_grid/dom_snapshot_script.rb
Constant Summary collapse
- DOM_EXTRACTION_TIMEOUT =
300
Instance Attribute Summary collapse
-
#compress_resources ⇒ Object
Returns the value of attribute compress_resources.
-
#dont_fetch_resources ⇒ Object
Returns the value of attribute dont_fetch_resources.
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#serialize_resources ⇒ Object
Returns the value of attribute serialize_resources.
-
#urls_to_skip ⇒ Object
Returns the value of attribute urls_to_skip.
Instance Method Summary collapse
-
#initialize(driver, urls_to_skip, dont_fetch_resources, serialize_resources = false, compress_resources = false) ⇒ DomSnapshotScript
constructor
A new instance of DomSnapshotScript.
- #process_page_script ⇒ Object
- #run ⇒ Object
- #script ⇒ Object
- #script_options ⇒ Object
Constructor Details
#initialize(driver, urls_to_skip, dont_fetch_resources, serialize_resources = false, compress_resources = false) ⇒ DomSnapshotScript
Returns a new instance of DomSnapshotScript.
42 43 44 45 46 47 48 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 42 def initialize(driver, urls_to_skip, dont_fetch_resources, serialize_resources = false, compress_resources = false) self.driver = driver self.urls_to_skip = urls_to_skip self.dont_fetch_resources = dont_fetch_resources self.compress_resources = compress_resources self.serialize_resources = serialize_resources end |
Instance Attribute Details
#compress_resources ⇒ Object
Returns the value of attribute compress_resources.
40 41 42 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 40 def compress_resources @compress_resources end |
#dont_fetch_resources ⇒ Object
Returns the value of attribute dont_fetch_resources.
40 41 42 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 40 def dont_fetch_resources @dont_fetch_resources end |
#driver ⇒ Object
Returns the value of attribute driver.
40 41 42 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 40 def driver @driver end |
#serialize_resources ⇒ Object
Returns the value of attribute serialize_resources.
40 41 42 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 40 def serialize_resources @serialize_resources end |
#urls_to_skip ⇒ Object
Returns the value of attribute urls_to_skip.
40 41 42 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 40 def urls_to_skip @urls_to_skip end |
Instance Method Details
#process_page_script ⇒ Object
50 51 52 53 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 50 def process_page_script '' # Applitools::Selenium::Scripts::PROCESS_PAGE_AND_POLL end |
#run ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 68 def run Applitools::EyesLogger.info 'Trying to get DOM snapshot...' script_thread = Thread.new do result = {} while result['status'] != 'SUCCESS' Thread.current[:script_result] = driver.execute_script(script) begin Thread.current[:result] = result = Oj.load(Thread.current[:script_result]) sleep 0.5 rescue Oj::ParseError => e Applitools::EyesLogger.warn e. end end end sleep 0.5 script_thread_result = script_thread.join(DOM_EXTRACTION_TIMEOUT) raise ::Applitools::EyesError.new 'Timeout error while getting dom snapshot!' unless script_thread_result Applitools::EyesLogger.info 'Done!' script_thread_result[:result]['value'] end |
#script ⇒ Object
64 65 66 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 64 def script "#{process_page_script} return __processPageAndSerializePoll(#{});" end |
#script_options ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/applitools/selenium/visual_grid/dom_snapshot_script.rb', line 55 def = [] .push("dontFetchResources: #{dont_fetch_resources}") .push("skipResources: [#{urls_to_skip}]") .push("compressResources: #{compress_resources}") .push("serializeResources: #{serialize_resources}") "{#{.join(', ')}}" end |