Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

» Selenium Webdriver
Sat Feb 04, 2017 6:47 pm by soumyamishrav@gmail.com

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

selecting search item values in drop down using selenium webdriver

View previous topic View next topic Go down

selecting search item values in drop down using selenium webdriver

Post by dhivyaavk on Fri Sep 21, 2012 5:30 pm

Hi,

I am new to selenium and i have coded using selenium webdriver.But i am not able to proceed please guide me for this scenario.

1.go to www.google.com.
2.Type cheese in the search box .It will display the respective cheese items like drop down in search box.In which i have to select cheese recipes.I am not able to proceed after the cheese.I dont know how to code for selecting the cheese recipes.Please guide me to proceed.i have been trying by selecting xpath and all but i dnt know how to do.

dhivyaavk

Posts : 2
Join date : 2012-01-02

Back to top Go down

Re: selecting search item values in drop down using selenium webdriver

Post by Sourav on Mon Oct 08, 2012 6:08 pm

Hi,
Whatever drop down you are seeing, its not simple drop down, its dynamic in nature. Try something simple as a new

Sourav
Active particpant
Active particpant

Posts : 17
Join date : 2012-06-28

Back to top Go down

Re: selecting search item values in drop down using selenium webdriver

Post by anemuday on Fri Oct 19, 2012 5:29 pm

Hi,

Below is my approach:
Code:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Forum_Google_Search
{
    public static void main(String[] args)
    {
        String str1,str2;
        str1="cheese";
        str2="cheesecake recipes";
        String str_xpath=null;
        boolean found=false;
       
       
        WebDriver driver= new FirefoxDriver();
        driver.get("http://www.google.com");
       
        WebElement obj_Search=driver.findElement(By.id("gbqfq"));
        obj_Search.sendKeys(str1);
       
        try {
            Thread.sleep(5000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
       
       
        int no_elements=driver.findElements(By.xpath("//*[@class='gssb_m']/tbody/tr")).size();
        for(int i=1;i<=no_elements;i++)
        {
            str_xpath="//*[@class='gssb_m']/tbody/tr["+i+"]";
            String x=driver.findElement(By.xpath(str_xpath)).getText();
            if(x.equals(str2))
            {
                found=true;
                break;
            }
        }
       
        if(found==true)
        {
            WebElement obj_lookingString=driver.findElement(By.xpath(str_xpath));
            obj_lookingString.click();
            System.out.println("Clicked on the link :"+str2);
        }
        else
        {
            System.out.println("Not able to find the link :"+str2+" mentioned");
        }
    }

}

anemuday
Active particpant
Active particpant

Posts : 11
Join date : 2012-10-11

Back to top Go down

Re: selecting search item values in drop down using selenium webdriver

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum