1

html snippet:

<div id="isc_PT" class="selectItemText" tabindex="5637" style="width:123px;height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" $9a="$9d" $89="isc_SelectItem_8" aria-expanded="false"></div>

If I select class I have 3 matching nodes. How can I handle that?

I have tried with

//div[contains(@id,'isc_PT')]

WebElement element=driver.findElement(By.xpath("//div[contains(@id,'isc_FX')]"));
            Select se=new Select(element);
            se.selectByVisibleText("MDialog");
  • This looks like Java, am I correct in my assumption? If so, which version are you using? Are you using Groovy as well? – Paul Muir Apr 26 '16 at 11:24
1
     WebElement element=driver.findElement(By.xpath("(//div[@class='selectItemText'])[2]"));
                Thread.sleep(5000);
                element.click();
                Thread.sleep(10000);
driver.findElement(By.xpath("(//nobr[text( )='MDialog'])[4]")).click();  
//driver.findElement(By.xpath("//nobr[text()='MDialog']")).click();
                element.click();
                Thread.sleep(10000);
                driver.findElement(By.name("description")).sendKeys("MDialog");
                Thread.sleep(10000);
  • Is it works now? – Bharat Mane Apr 26 '16 at 12:07
  • always try to avoid use of 'Thread.sleep' in your code. Instead of this you may use 'implicitlyWait'. – Bharat Mane Apr 26 '16 at 12:09
0

First of all Select is not working with Div or any other element.

Select are use only with element is having Select tag and inside it, only having option tags.

Solution :

WebElement element=driver.findElement(By.xpath("//div[contains(@id,'isc_FX')]"));
element.click();
driver.findElement(By.xpath("//*[text()='MDialog']")).click();

Try this.

Comment my answer If any query.

  • no not working ,not able to find the x path it is changing – Sushma Arun Apr 26 '16 at 7:22
  • no not working.<div id="isc_1BW" class="selectItemText" tabindex="8913" style="width:123px;height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" $9a="$9d" $89="isc_SelectItem_12" aria-expanded="false"></div> – Sushma Arun Apr 26 '16 at 7:25
  • you can use class property. Please let me know If it is working or not so I can update answer. driver.findElement(By.className("selectItemText")); – Sagar007 Apr 26 '16 at 8:15
  • element is not click able at point element.click(); – Sushma Arun Apr 26 '16 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.