From 98c1e49a3a863f1c2ac2665243fef7e86fa4a199 Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Wed, 11 May 2022 16:26:30 +0200 Subject: [PATCH 1/3] add selenium method to get source --- examples/tests/cases/case_selenium.yaml | 9 +++++++++ lib/core/device.rb | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/tests/cases/case_selenium.yaml b/examples/tests/cases/case_selenium.yaml index 33fb2301..ae59bdec 100644 --- a/examples/tests/cases/case_selenium.yaml +++ b/examples/tests/cases/case_selenium.yaml @@ -30,3 +30,12 @@ TestSwitchFrameId: Id: "intercom-frame" - Type: switch_frame Value: "intercom-frame" + +TestGetSource: + Roles: + - Role: desktopChrome + App: desktop + Actions: + - Type: navigate + Value: https://www.testdevlab.com/ + - Type: get_source diff --git a/lib/core/device.rb b/lib/core/device.rb index 5b6c5f55..9dec33cc 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -835,7 +835,12 @@ def get_contexts(action) # parses and saves the source code for currect page. def get_source(action) - source = @driver.get_source + source = nil + begin + source = @driver.get_source + rescue => e + source = @driver.page_source + end File.write("./page_source.xml", source) end From 32e920890089190a6db59561efe2a65c380f0951 Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Wed, 29 Jun 2022 15:33:10 +0200 Subject: [PATCH 2/3] fix comments with remove begin rescue --- lib/core/device.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/device.rb b/lib/core/device.rb index 9dec33cc..5d9b0624 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -836,10 +836,10 @@ def get_contexts(action) # parses and saves the source code for currect page. def get_source(action) source = nil - begin - source = @driver.get_source - rescue => e + if @platform.nil? || @platform == "desktop" source = @driver.page_source + else + source = @driver.get_source end File.write("./page_source.xml", source) end From b5b23e9ed7144a6bd9a0de8a7e6ac4b1e23b5a7a Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Wed, 29 Jun 2022 15:39:34 +0200 Subject: [PATCH 3/3] optimize code --- lib/core/device.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/core/device.rb b/lib/core/device.rb index 5d9b0624..e54d4752 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -835,11 +835,10 @@ def get_contexts(action) # parses and saves the source code for currect page. def get_source(action) - source = nil - if @platform.nil? || @platform == "desktop" - source = @driver.page_source + source = if @platform.nil? || @platform == "desktop" + @driver.page_source else - source = @driver.get_source + @driver.get_source end File.write("./page_source.xml", source) end