Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

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 Today at 7:17 am


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