Selenium webdriver - Unable to select element from datalist

467 views
Skip to first unread message

Ashwini g s

unread,
Mar 9, 2015, 10:41:39 AM3/9/15
to seleniu...@googlegroups.com
Steps to reproduce

1. Login into Face Book account.
2.Click on Message link.
3.Click on New Message button.
4.Enter name(first few letters of the name for example rag to search raghu prasad) in "To" field.
5.Select particular name from auto-popup.
6.Type text in text area box.
7.Click on send button

What is the expected output? What do you see instead?
Expected Output:Message should be sent to selected person.

Actual Output:Not able to select name from auto-popup (Fails in step 5 using webdriver).

Selenium version:2.45.0
OS:Windows
Browser: Mozilla Firefox
Browser version:33.1.1



Script:

driver.findElement(By.xpath("//div[2]/div/div/div/div/div/div/button")).click();
    driver.findElement(By.xpath("//td[2]/div/div[2]/div/div/input")).clear();
    driver.findElement(By.xpath("//td[2]/div/div[2]/div/div/input")).sendKeys("ashwini gs gs");
     driver.findElement(By.xpath("//textarea")).clear();
    driver.findElement(By.xpath("//textarea")).sendKeys("hi");
    driver.findElement(By.xpath("//div[2]/div[2]/label/input")).click();


Message-Autopopup.png

SantoshSarma

unread,
Mar 10, 2015, 6:33:43 AM3/10/15
to seleniu...@googlegroups.com
In your code you missed to click that particular name from that search results.

that you can do using below xpath

1. Login into Face Book account.
2.Click on Message link.
3.Click on New Message button.
4.Enter name(first few letters of the name for example rag to search raghu prasad) in "To" field.

5==>  driver.findElement(By.xpath("//li[@role='option']//span[text()='Ashwini Gs Gs']")).click();
Reply all
Reply to author
Forward
0 new messages