Share
Go down
aks
Posts : 5
Join date : 2011-01-30

Query - web driver element click is not working

on Sun Jan 30, 2011 8:36 pm
Here is my code snnipet -

WebDriver driver = new InternetExplorerDriver();
driver.get("https://localhost:8080/fileServer/Tomcat/configuration.jsp");
...
...
...
System.out.println("Title " + driver.findElement(By.id("auto-gen15")).getAttribute("title")); // This line gives proper output

driver.findElement(By.id("auto-gen15")).click(); // This line is not working and even no error is thrown...program completes without any error.
.........
.....


When tried to record the testcase from selenium IDE and then statement comes as
selenium.click("auto-gen15");

Please help me, i m stuck here and cant find any reason for the issue. Thanks a lot in advance !!
avatar
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
http://seleniumforum.forumotion.net

Re: Query - web driver element click is not working

on Mon Jan 31, 2011 7:40 pm
Hi,
may the element is not id , it may be a name. try to find out the exact id with the help of firebug.

If all is fine then try to click the element by following way:
Code:

//first declare the webelement
      WebElement oSearchButton = oWebDriver.findElement(By.name("btnG"));
     
      //then perform operation on it
      oSearchButton.click();

I think you directly used the element without defining. May be this will solve your problem.
aks
Posts : 5
Join date : 2011-01-30

Re: Query - web driver element click is not working

on Mon Jan 31, 2011 8:02 pm
Hi Adviser..thanks for ur reply.

I used firebug only to find the id of button and its correct.
By id i m able to get the button but still click operation is not working even by using ur way of defining element.

here is the html code of button from firebug -


?button type="button" class="btn-text coreSave" id="auto-gen15" title="Save"> ?/button

replace question mark with angular brackets


Last edited by aks on Mon Jan 31, 2011 8:08 pm; edited 1 time in total
avatar
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
http://seleniumforum.forumotion.net

Re: Query - web driver element click is not working

on Mon Jan 31, 2011 9:49 pm
I think you Id is auto generated as name suggest which changes during run time. Please check whether it's changing at runtime or it's a static.
aks
Posts : 5
Join date : 2011-01-30

Re: Query - web driver element click is not working

on Tue Feb 01, 2011 6:00 pm
Thanks Adviser...
Didnt understand the exact issue but below statement solved my problem -

driver.findElement(By.id("auto-gen15")).sendKeys(Keys.ENTER)

Instead of click i used send "Enter" key
ChuckFirment
Posts : 2
Join date : 2011-08-24

Re: Query - web driver element click is not working

on Wed Aug 24, 2011 4:15 am
Aks,

Did you learn any more about the cause of this? I have a test that performs a Click command. It works with the FirefoxDriver and InternetExplorerDriver, but does not work with the ChromeDriver. SendKeys works for Chrome, but I actually want to send a click, not sendkeys.

Did you ever find out more?

Chuck
constantino.cronemberger
Posts : 1
Join date : 2012-06-28

Re: Query - web driver element click is not working

on Thu Jun 28, 2012 8:57 pm
SendKeys is a limited workaround because it only works when the window has the focus. In my case this does not work because I want to run multiple instances in parallel so only one can have the focus...
Sponsored content

Re: Query - web driver element click is not working

Back to top
Permissions in this forum:
You cannot reply to topics in this forum