Not able to locate a element on page

64 views
Skip to first unread message

Happy_coder

unread,
Dec 19, 2012, 1:27:25 PM12/19/12
to webd...@googlegroups.com
Hi

I am trying to record a selenium code that fill some values on page

"http://www.morganstanley.com/about/careers/careersearch.html " in field search by name "search by keyword"

The Xpath displayed by firepath is ".//*[@id='com.peopleclick.cp.formdata.SEARCHCRITERIA_KEYWORDS']". when i try to use the same
in Webdriver code it fails to locate the element

i tried css selector method too but in vain

Can anybody can help me on that

Thanks in advance

ASP

unread,
Dec 19, 2012, 2:33:55 PM12/19/12
to webd...@googlegroups.com

try this 

WebElement element = webdriver.findElement(By.id("com.peopleclick.cp.formdata.SEARCHCRITERIA_KEYWORDS"));

ASP

Karan

unread,
Dec 20, 2012, 10:05:22 AM12/20/12
to webd...@googlegroups.com
Hi ASP

I have tried this too but it fails when we run the Java Code in Eclipse , though in IDE its works fine and test get passed.
IF we try to find highlight the same in Firefinder too , no element get highlighted.

And thanks for reply

ASP

unread,
Dec 20, 2012, 1:38:22 PM12/20/12
to webd...@googlegroups.com
can you post your code ?  have you implemented screenshots when test fails ? that will give an idea whats happening while locating element 

Anand

unread,
Dec 20, 2012, 3:26:25 PM12/20/12
to webd...@googlegroups.com
The element you are trying to find is inside an iframe. So you will have to first switch to the iframe and then find the element. 
You can try this : 

//First switch to iframe 
driver.switchTo().frame(driver.findElement(By.id("Search")));
WebElement e = driver.findElement(By.xpath("//input[@id='com.peopleclick.cp.formdata.SEARCHCRITERIA_KEYWORDS']"));

//do further stuff .... and then switch back to form 

driver.switchTo().defaultContent();

Let me know if it works. 

Karan

unread,
Dec 25, 2012, 12:21:34 PM12/25/12
to webd...@googlegroups.com
Thanks so much Anand for helping on this. the method you mentioned below worked for me.

Thanks once again :)

Karan
Reply all
Reply to author
Forward
0 new messages