Reputation: 1028
So I've got a list of clickable links using selenium-webdriver in Ruby:
users = driver.find_elements(:class, "username")
of course, I can click on them.
users.first.click
But that opens it in the same window. I want to open it in a new window, load the window, and then close that window, so I don't lose track/context of additional links on the page. I can't find how to do this. The closest I have is
driver.execute_script("window.open('#{users.first}')")
But that doesn't extract a link from it, since its just a target to click on, not a URL. So I need to either extract the URL from the element, or have some other way to open a new window.
Upvotes: 1
Views: 829