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,300 points
1,967 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,500 points

Related Questions In Selenium

0 votes
3 answers

How to print text from a list of all web elements with same class name in Selenium?

Try using List <WebElement> to access all similar elements ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
87,447 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to take Screenshot of a webpage in Selenium with Ruby

Hi Sunita, you can use following code ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
1,571 views
0 votes
2 answers

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,500 points
13,684 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,148 views
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,910 points
7,226 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,879 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,500 points
6,058 views
0 votes
2 answers

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

Hey, try using following code command to ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,140 points
1,438 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP