Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am automating Peoplesoft through Selenium. Web driver is able to locate the web element:

System.println.out(driver.findElements(By.id("Element_id").getAttribute("name"));

Web driver prints the name attribute of that element, but when I am trying to click it fails:

driver.findElements(By.id("Element_id").click();

although it does not throw error message, and the web driver remain in running status, without terminating itself.

Please help.

share|improve this question
add comment

2 Answers

There are a couple of explanations. The most common one is that the element that is identified is actually a different element than you expected to identify. It's less common with id's which should be unique, but it can happen still if a dev accidentally gives multiple elements on a page the same ID, or if there is something duplicating an element and the logic doesn't exist to update the ID for each duplicate element.

Another explanation could be that the element you found is not the element that is expected to be clicked. Maybe it is a child (or in rarer cases a parent or sibling) of the element that is actually receiving the click events. Try clicking on the parent or ancestor element.

Another explanation could be that Selenium is performing the click, but the element is actually expecting some event to be fired that Selenium's "click" doesn't trigger. Maybe you have to hover over the element first and then click? Maybe it's something more cryptic like expecting a non-standard event?

Hopefully it's one of these explanations, if not let me know and maybe we can troubleshoot further.

share|improve this answer
    
Explanations are quite helpful ,but the same web element web driver is able to click ,when we are simply opening that web page and doing click operation, but when i am trying to do some other operations like , sending keys to certain web elemets on the same page ,selecting some values from look up values etc., the web driver is not able to click in such case. –  saurav Sep 15 '13 at 14:05
    
Then it sounds like you are almost for sure hitting the first case. The other operations must be adding an additional element with the same id somewhere else on the page. In this case, you need to identify the element in some other way. CSS Selector or XPath can be used to be more specific about what the parent/ancestor elements are as well. –  Sam Woods Sep 15 '13 at 15:44
add comment

Try using SendKeys

driver.findElements(By.id("Element_id").SendKeys("\n");
share|improve this answer
    
Hi, Brandon. Would sending a newline character necessarily work to simulate a click action? I find it difficult to accept that this would work for, for instance, selecting a radio button. –  Kate Paulk Sep 16 '13 at 12:00
    
You're correct, there are limited use cases. In my personal experience, I've had success using this method on standard links, buttons, and "entering" off of form fields in IE-based tests. –  Brandon Smith Sep 22 '13 at 1:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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