Using findElements in groovy pages

Hi there,

Apologies if this question seems trivial,.. but I am very very new to groovy/selenium as part of a maven system I’ve been throws at and am in need to understand what I am missing in trying to get this method to work.

The error I am getting is below:


groovy.lang.MissingMethodException: No signature of method: GebConfig.findElements() is applicable for argument types: (org.openqa.selenium.By$ByName)

I’m in need to locate elements on a web page and would like to use the findElements method, however my code is in groovy as part of step definitions.

I have ended up with the following after lots of attempts but am getting nowhere:

 

package step_definitions
import features.support.Requests

import geb.*

import org.apache.commons.io.*

import org.openqa.selenium.By

import org.openqa.selenium.WebDriver

import org.openqa.selenium.WebElement

import org.openqa.selenium.*

import org.openqa.selenium.remote.*

import cucumber.api.groovy.EN.*
When(~/^find the element named "(.*?)"$/) { String myName ->
WebElement myElement = driver.findElements(By.name(btnName));
}

I know I can use things like the below for a button and similar for other things like radio buttons and input fields:

browser.$(‘input’, name: ‘btnK’)

$(‘input’, name: ‘btnK’)

 

But I’d prefer to know how to use the findElements approach.

 

Any help would be appreciated.

 

Thanks,

 

Jim…..

Default Asked on March 29, 2019 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.