Sha256: 08ef86816fda6fe8e3cb2105c84315f06c0074fa4c17232740e348eeba5581b8

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.

require 'uri'

module Async
	module WebDriver
		module Scope
			# Helpers for navigating the browser.
			module Navigation
				# Navigate to the given URL.
				# @parameter url [String] The URL to navigate to.
				def navigate_to(url)
					session.post("url", {url: url})
				end
				
				alias visit navigate_to
				
				# Get the current URL.
				# @returns [String] The current URL.
				def current_url
					session.get("url")
				end
				
				# Get the path component of the current URL.
				# @returns [String] The current path.
				def current_path
					URI.parse(current_url).path
				end
				
				# Navigate back in the browser history.
				def navigate_back
					session.post("back")
				end
				
				# Navigate forward in the browser history.
				def navigate_forward
					session.post("forward")
				end
				
				# Refresh the current page.
				def refresh
					session.post("refresh")
				end
			end
		end
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
async-webdriver-0.6.0 lib/async/webdriver/scope/navigation.rb
async-webdriver-0.5.0 lib/async/webdriver/scope/navigation.rb
async-webdriver-0.4.0 lib/async/webdriver/scope/navigation.rb
async-webdriver-0.3.1 lib/async/webdriver/scope/navigation.rb
async-webdriver-0.3.0 lib/async/webdriver/scope/navigation.rb
async-webdriver-0.2.0 lib/async/webdriver/scope/navigation.rb