How to return an arraylist of WebElements using Jquery in selenium web driver

374
November 23, 2016, at 7:15 PM
ArrayList<WebElement> list=(ArrayList<WebElement>) js.executeScript("return $('input:radio');");

I am trying to return a list of elements with input type radio using jQuery in executeScript method.

Below is the exception that I get:

com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.util.ArrayList

Answer 1

Why are you using JQuery wrapped in JavaScript inside Java to do this? :)

Have you tried something simple like

List<WebElement> list = driver.findElements(By.cssSelector("input[type='radio']"));
Rent Charter Buses Company
READ ALSO
Deleting bootstrap slider using jquery

Deleting bootstrap slider using jquery

How can I delete a slider created as below,.

429
JQuery onBlur event not firing

JQuery onBlur event not firing

This question seems elementary but it doesn't matter what I do ( based on the various posts on SOV I went through ) I just cannot get this event to fire in my Devextreme app.

586
jquery data tables get data from selected rows

jquery data tables get data from selected rows

I have a jquery datatable, and have checkboxes which set the row selected class to the rows which are selected. However when I try to get the first column data from these selected rows, it gives me objects.

515