Imagine there is a button that opens a JavaScript tooltip to show data to users and allows them to easily copy.
<!DOCTYPE html>
<html>
<body>
<button id="show-coordinates" onclick="prompt('This is your coordinates', '4.684032, -74.109663');">
Show Coordinates
</button>
</body>
</html>
Run codeHide resultWhen automating a button using Selenium WebDriver, how to get the value of such a help window (i.e., the coordinates in this case need these values for future use)? The WebDriver API provides a method for retrieving the text of such a tooltip (in this example, this This is your coordinates), but not the value, as far as I can see.
You can also consider the original JavaScript solution (without resorting to the attribute of the onclickelement <button>, of course, I put an event handler in the DOM to just illustrate the problem).
driver.find_element(:id, 'show-coordinates').click
popup = driver.switch_to.alert
puts popup.text