Enable to click on 'find hotels' using Selenium-Java

247 views
Skip to first unread message

Ashvini Sharma

unread,
Aug 4, 2013, 9:45:54 PM8/4/13
to webd...@googlegroups.com
Hi,

I am using Selenium (web driver) - Java. I picked a travel site to do demo of automation.
On this travel site, at home webpage, I need to place following input before submit the form.
1-Provide City name
2-Date from and Date To
3-Click on Find hotel button.

I am able to do following:
1- Done
2- Done
3- Unable to click on Find hotel button.

On 3rd step, whenever I am clicking on 'Find button' through selenium code, it redirect page to some other website (not sure from where its redirection is coming).
My question is: is I am doing something wrong? Below are the details:

Web page source code:
   <div class="clear"></div>
                        <div class='multiSearchBox' >
                                <div class='clear'></div>
                        </div>
                        <div class="block_bottom">
                        <div class="bottom">
                        <button class="search" type="submit">Find Hotels</button>
                        <input type="hidden" name="passengers" autocomplete="off" value="">
                        </div>
                        </div>

                        <div class="clear"></div>
                        </form>

----------
here is the button code which shows up in inspect element:
<button class="search" type="submit">Find Hotels</button>

--------
Here is my code:
public void SubmitForm() {
WebElement Submit = Driver.findElement(By.className("search"));
System.out.println(Submit.getText());
Submit.submit();
}

I tried with following as well:
Submit.click();

But no luck.
However, I am getting button label: 'Find Hotels' in output but page gets re-directed to some other search page.
Doing manual click 'Find hotels' button on web page works fine.

I tried with Chrome and Friefox, I am facing same problem.
Please see if some can help.

Mike Riley

unread,
Aug 5, 2013, 3:28:17 PM8/5/13
to webd...@googlegroups.com
Are you not getting any error when you do click()?

I was thinking that maybe you are trying to click on it before it is enabled, because your code looks fine to me.

Mike

Ashvini Sharma

unread,
Aug 6, 2013, 1:26:08 AM8/6/13
to webd...@googlegroups.com
Hi Mike,

Thank you for your response.
I am not getting error on click(), rather its redirect me to some other website search page.
However, if I do manually than search is working fine.

This is something like, web site is behaving differently when I am trying to click on Find hotel button through selenium.
But, if I do manual (i.e. provide all input and click on using mouse manually) than site shows correct search results.

I tried same code with other sites and its working fine.
I tried with Firefox / Chrome and function like submit, click, used Xpath but no luck.

I posted this issue on other forums as well, but no body is able to answer.
It looks like Selenium web driver is culprit here. But I do not have any evidence. 

Thanks,
Ashvini

SANTHOSH BABY

unread,
Aug 6, 2013, 2:11:08 AM8/6/13
to webd...@googlegroups.com
As per your earlier mail , no body able to answer &  Well Selenium webdriver is not culprit . Let me try   this  
If you are on  Teamviwer i would connect to your machine and fix it . Otherwise if your application is  exposed  to public . then let me know the URl would resolve .it.

Thank you 
santhosh

Thank you
Cheers.
rsz_santhosh.jpg
Santhosh Baby

Santhosh Software Automation  Engineer
 



Think GREEN. Please consider the environment before printing this email

"When The Winds of Change Blow..... Some people Build Walls & Others Windmills.... Attitude Matters...."


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

rsz_santhosh.jpg
image001.gif

SANTHOSH BABY

unread,
Aug 6, 2013, 7:54:59 AM8/6/13
to webd...@googlegroups.com
Hi , 
This line worked for me.. in clicking the  Find button  

driver.findElement(By.xpath(".//*[@id='innerBox']/div[3]/form/div[4]/div/button")).click();

Pretty straight forward . 





Thank you
Cheers.
rsz_santhosh.jpg
Santhosh Baby

Santhosh Software Automation  Engineer
 



Think GREEN. Please consider the environment before printing this email

"When The Winds of Change Blow..... Some people Build Walls & Others Windmills.... Attitude Matters...."


image001.gif
rsz_santhosh.jpg

Ashvini Sharma

unread,
Aug 7, 2013, 4:52:59 AM8/7/13
to webd...@googlegroups.com
This doesn't work either.
This is Xpath from Google chrome inspect element.

Currently I can see that website is tricky as it has some hidden elements.
And Selenium webdriver is not able to handle this situation straight forward. 

Any help will be appreciated.

SANTHOSH BABY

unread,
Aug 7, 2013, 6:38:10 AM8/7/13
to webd...@googlegroups.com
Hello , 

When something  doesnt work , you cant say selenium is not able to handle such things. 
I tried for the website you shared with me on my machine . It was straight forward button click .   Nothing big logic  .  involved  here to decode this issue. 

Thank you 
Santhosh 

On Wed, Aug 7, 2013 at 2:22 PM, Ashvini Sharma <ashv....@gmail.com> wrote:
This doesn't work either.
This is Xpath from Google chrome inspect element.

Currently I can see that website is tricky as it has some hidden elements.
And Selenium webdriver is not able to handle this situation straight forward. 

Any help will be appreciated.


On Tuesday, August 6, 2013 5:24:59 PM UTC+5:30, Santhosh Baby wrote:
Hi , 
This line worked for me.. in clicking the  Find button  

driver.findElement(By.xpath(".//*[@id='innerBox']/div[3]/form/div[4]/div/button")).click();

Pretty straight forward . 



Ashvini Sharma

unread,
Aug 7, 2013, 6:40:34 AM8/7/13
to webd...@googlegroups.com
Can you please share the url that you are getting after click on 'Find hotels' button through selenium code?


--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/5rj9cPMBeXo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.

SANTHOSH BABY

unread,
Aug 10, 2013, 11:00:43 AM8/10/13
to webd...@googlegroups.com, Ashvini Sharma
Hi ,
Im Using webdriver 2.34  only for the execution . I Was able to perform  the action which you said was failing at your end. I did not see any issues nor defect  selenium. Please check your framework design how you implemented . that could resolve . .

Thank you 
Santhosh

On Sat, Aug 10, 2013 at 2:00 AM, Ashvini Sharma <ashv....@gmail.com> wrote:
Never mind, I got the issue. However, you were right its working straight forward, but there was an issue in Webdriver the way I used to code.
My coding way was not correct but that was upto coding standards and architecture, however if someone follows java rules than ever code should be correctly executable regards the coding standards. 

I have logged a defect for webdriver 2.34 and Dev is looking into it.

Thanks.
 




On Wed, Aug 7, 2013 at 2:22 PM, Ashvini Sharma <ashv....@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages