Module: Async::WebDriver::XPath

Defined in:
lib/async/webdriver/xpath.rb

Overview

Helpers for working with XPath.

Class Method Summary collapse

Class Method Details

.escape(value) ⇒ Object

Escape a value for use in XPath.

XPath 1.0 does not provide any standard mechanism for escaping quotes, so we have to do it ourselves using concat.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/async/webdriver/xpath.rb', line 15

def self.escape(value)
	case value
	when String
		if value.include?("'")
			"concat('#{value.split("'").join("', \"'\", '")}')"
		else
			"'#{value}'"
		end
	else
		value.to_s
	end
end