Module: Sapphire::WebAbstractions::WebBrowser
- Included in:
- ChromeBrowser, FireFoxBrowser, InternetExplorerBrowser
- Defined in:
- lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb
Instance Attribute Summary collapse
-
#rootUrl ⇒ Object
readonly
Returns the value of attribute rootUrl.
Instance Method Summary collapse
- #CurrentUrl ⇒ Object
- #Init(url) ⇒ Object
- #NavigateTo(page) ⇒ Object
- #Reload ⇒ Object
- #Run(background) ⇒ Object
- #SetRootUrl(url) ⇒ Object
- #ShouldNavigateTo(page) ⇒ Object
- #ShouldShow(page) ⇒ Object
- #ShouldTransitionTo(url) ⇒ Object
Instance Attribute Details
#rootUrl ⇒ Object (readonly)
Returns the value of attribute rootUrl.
5 6 7 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 5 def rootUrl @rootUrl end |
Instance Method Details
#CurrentUrl ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 32 def CurrentUrl wait = Selenium::WebDriver::Wait.new(:timeout => 10) url = wait.until { x = self.current_url x unless x == nil } url end |
#Init(url) ⇒ Object
7 8 9 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 7 def Init(url) @rootUrl = url end |
#NavigateTo(page) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 20 def NavigateTo(page) if(page.is_a? Class) nav = page.new self else nav = page end self.browser.get "https://" + nav.Url nav.Init nav end |
#Reload ⇒ Object
41 42 43 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 41 def Reload self.browser.get self.CurrentUrl end |
#Run(background) ⇒ Object
57 58 59 60 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 57 def Run(background) scenario = background.new self scenario.Run end |
#SetRootUrl(url) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 11 def SetRootUrl(url) if(url.instance_of?(String)) self.Init(url) else x = url.new().Url self.Init(x) end end |
#ShouldNavigateTo(page) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 45 def ShouldNavigateTo(page) if(page.is_a? Class) nav = page.new self else nav = page end temp = self.CurrentUrl.upcase.start_with?("HTTP://" + nav.Url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + nav.Url.upcase) return temp, nav end |
#ShouldShow(page) ⇒ Object
62 63 64 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 62 def ShouldShow(page) self.ShouldNavigateTo page end |
#ShouldTransitionTo(url) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb', line 66 def ShouldTransitionTo(url) if(url.instance_of?(String)) temp = self.CurrentUrl.upcase.start_with?("HTTP://" + url.upcase) || self.CurrentUrl.upcase.start_with?("HTTPS://" + url.upcase) @rootUrl = url else x = url.new().Url temp = self.CurrentUrl.upcase.start_with?("HTTP://" + x.upcase) || temp = self.CurrentUrl.upcase.start_with?("HTTPS://" + x.upcase) @rootUrl = x end return temp end |