Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

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