How to find a list of elements that end with a particular string by using Selenium with Ruby

0 votes

Below is a method to check if the panel is displayed or not.

def verifyNav(section)
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { @driver.find_element(:id => section + '-panel').displayed? == true }
end

I want to add code, which says that all other elements that have an id that ends in '-panel' should not be displayed.

I found that I can use the end_with method in which there is a find_elements method that returns a list of matching elements.

a = 'radio-panel'
a.end_with?('-panel')

returns true.. but if I try to call

@driver.find_elements(:id => end_with?('-panel'))

I get an error saying that end_with is an undefined method.

Any ideas on what I can do?

Mar 27, 2018 in Selenium by code_ninja
• 6,160 points
116 views

1 answer to this question.

0 votes

The problem is that, the end_with method is not defined anywhere. Try using a

CSS selector: @driver.find_elements(:css => '[id$="-panel"]')

Hopefully this should work.

answered Mar 27, 2018 by nsv999
• 5,050 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
246 views
0 votes
1 answer

Is it possible for a website to detect that we are using Selenium with ChromeDriver

Selenium tests for pre-defined javascript variables which ...READ MORE

answered Apr 27, 2018 in Selenium by Meci Matt
• 9,400 points
1,927 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
628 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
256 views
0 votes
1 answer

Need to perform parallel execution (multiple browser sessions) with Selenium & TestNG by using @BeforeSuite

@Beforesuite annotated method runs before the testNG.XML ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,050 points
1,100 views
0 votes
1 answer

How can we take screenshots of tests in Selenium 2 using C#

We can take screenshots using below function ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,050 points
131 views