JDBC Exercise | leadapp | comparing values of the drop down | Selenium Forum
M
Posted on 28/01/2016
Hi,

I am currently performing the exercise where you have demonstrated the way to compare the values of the CATEGORY drop down from the leadapp application and the values fetched from the DB. In the training videos it’s done through Selenium RC and junit.

I am trying to do it with selenium WebDriver and Junit. There is an issue that I am encountering is

In selenium RC you have used a string array to store the values from the Xpath in the leadapp application and the code is below.
String actual[] = selenium.getSelectOptions("//*[@id='Field7']");
List<String> actual_list=Arrays.asList(actual);

You are converting the string array to a list so that the values in any order would be compared to the result in resultset (which will be obtained from the database). Since I am using web driver, my code to fetch the values from the category drop down is like this

List<WebElement> actual_list= webdriver.findElements(By.xpath("//*[@id='Field7']"));

Now when I compare the actual_list with the output from resultset(which will be obtained from the database), I get the status as false instead of true when I compare using the below.

System.out.println(actual_list.contains(rs.getString("CT_NAME")));

Though the values are the same from the application and the database and I am able to print them separately but when I compare they appear to be false. So should I convert the List<WeblElement> reference to a List<String>. Will that solve the issue and if yes how can I covert that? Please post your inputs.

Regards,
Arun

M
Replied on 29/01/2016

[quote:tkawz5me]System.out.println(actual_list.[color=#FF0000:tkawz5me]contains[/color:tkawz5me](rs.getString("CT_NAME")));
[/quote:tkawz5me]

try [color=#FF0000:tkawz5me].equals[/color:tkawz5me]