0

I am trying to automate the drop down in the website Naukri.com. That drop down consists of multi select check-boxes. How can we automate it using Selenium Web driver?

The structure of the drop list is:

<div class="DDwrap">
<ul class="DDsearch">
    <li class="tagit" data-id="tg_indCja_a8_A">
         <span class="tagTxt">Accounting , Finance</span>
         <span class="dCross"></span>
    </li>
   <li class="frst" style="float: left;">
   <input id="cjaInd" class="srchTxt" type="text" placeholder="" name="" autocomplete="off"   style="width: 30px;">    
   <input id="hid_indCja" type="hidden" name="indType" value="["8"]">
   </li>
</ul>
</div>

Can anyone help me regarding this?

0

1 Answer 1

1

Check out the code below, It navigates to the concerned form, opens the dropdown of "Industry" and selects two checkboxes: 'Accounting , Finance' and 'Government , Defence':

WebDriver driver = new FirefoxDriver(); //Opening firefox instance

driver.manage().window().maximize(); //maximizing window
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //Giving implicit timeout of 20 seconds

driver.get("http://www.naukri.com/");


//Since there are two windows popping up, hence switching and closing the unnecessary window.
Set<String> windows = driver.getWindowHandles();        
Iterator iter = windows.iterator();
String parentWindow = iter.next().toString();
String childWindow = iter.next().toString();        
driver.switchTo().window(childWindow);
driver.close();
driver.switchTo().window(parentWindow);

//Hovering over "Jobs"
Actions act = new Actions(driver);
WebElement jobs = driver.findElement(By.xpath("//ul[@class='midSec menu']//div[.='Jobs']"));
act.moveToElement(jobs).build().perform();

//Clicking on "Advance Search"
WebElement Adv_search = driver.findElement(By.xpath("//ul[@class='midSec menu']/li[1]//a[.='Advanced Search']"));
act.moveToElement(Adv_search).click().perform();

//Clicking on the industry dropdown
driver.findElement(By.xpath("//div[@class='DDinputWrap']/input[contains(@placeholder,'Select the industry')]")).click();

//Selecting the checkbox containing text as "Accounting"
driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Accounting')]")).click();

//Selecting the checkbox containing text as 'Government' 
driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Government')]")).click();
Sign up to request clarification or add additional context in comments.

4 Comments

@Riki: If it has worked for you, please mark it as answer too. Thanks.. :)
I think i will catch you up later too..since i'm new to automation ;)
Hi Shubh, Can you also help in automating the CREATE JOB ALERT page as there are some dynamic class names used there. It worked for me if i am removing //div[@class='DDWrap' from Industry and starting xpath from //input. But that is not unique Can you help please?
It's better if you ask a new question. It will help others, help you too. Elongating the conversation on question aside from what was originally posted, is not good.. Thanks.. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.