How to extract a Selenium element from a Capybara element?

I am more familiar with Java and Selenium than with Ruby and Capybara and SitePrism, so I apologize if this question is rather fat.

Selenium has a very useful class for managing Select tags, Selenium :: WebDriver :: Support :: Select , which can be created by passing it the Selenium Element ( Selenium :: WebDriver :: Element ) representing the selection. I would like to get a Select object to use its convenient methods.

Using SitePrism and Capybara, however, the standard method for defining elements gives me access to the element selected by the Capybara Element class, Capybara :: Node :: Element , and I cannot find an easy way to extract the main Selenium element from the Capybara element.

I searched for alternatives and found the Capybara #select method , but it seems very limited to me, since it looks like it makes you choose by value and has very narrow parameters for determining the choice on the page.

Is there an easy way to create Select from SitePrism / Capybara selenium? Or is there a better way to do this whole thing? Thanks!

+6
source share
1 answer

Ah, I found it. It was right in Capybara :: Node :: Element all the time. The #native method returns the native element from the driver. This can then be passed to the Selenium Select initialization method to successfully create the Select.

+5
source

Source: https://habr.com/ru/post/953584/


All Articles