# Login web page using mechanize

**URL:** <https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237>\
**Category:** Ruby\
**Created:** [November 4, 2012, 8:41pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237 "2012-11-04T20:41:38Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [November 9, 2012, 5:41pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237/21 "2012-11-09T17:41:25Z")

</div>

For button click on your page example this is correct way to click it:  
find(:xpath, “//\*[@id=“sImage1”]”).click

2012/11/9 john smith [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [November 9, 2012, 5:06pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237/22 "2012-11-09T17:06:21Z")

</div>

ive been trying to look up xpath and css selectors. i have my program  
fill out the email and all i need to figure out now is to press the send  
button. but its not like the other buttons i have used.

| &nbsp; |
| |
| &nbsp; | &nbsp; | 

```
    <tr><td colspan="3">&nbsp;</td></tr>
    <tr>
      <td width="0%">&nbsp;</td>
      <td width="0%">
  <a 

```

href=“javascript:exit(’/online/valdoc/ea\_askaqsend?\_\_i=1352473481343-4376714975339252553’)”\> ![](https://www.ruby-forum.com/01/images/pg3_but2_new.gif)&nbsp;  
\<!–

| |

--\>

that is the code from the pages source file. this is the send button i  
need to click. but it says cannot find button or link with value send.  
so i started looking into href, xpath, and css tried like 100 different  
things and still no dice. any suggestions? what kind of button is it  
would probably help a lot? i dont know how to tell if its css or xpath.

 |

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [November 9, 2012, 6:36pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237/23 "2012-11-09T18:36:24Z")

</div>

GOT IT!!!

find(:xpath, “//_[@class=‘CLiKStdleft’]").click  
find(:xpath, "//_[@src=’/01/images/pg3\_but2\_new.gif’]”).click

theres the missing code! feels good now that it works though. thank you  
for all your help!

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [November 9, 2012, 7:27pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237/24 "2012-11-09T19:27:49Z")

</div>

> find(:xpath, “//\*[@class=‘CLiKStdleft’]”).click

It could be written with CSS selectors:  
find(:css, “.CLiKStdleft”).click  
or shorter (since CSS is default selector in Capybara):  
find(“CLiKStdleft”).click

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [November 9, 2012, 5:45pm UTC](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237/25 "2012-11-09T17:45:49Z")

</div>

“Иван Бишевац” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote in post #1083769:

> For button click on your page example this is correct way to click it:  
> find(:xpath, “//\*[@id=“sImage1”]”).click
> 
> 2012/11/9 john smith [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

“id=sImage1” is the button to log into the webpage. i have already  
gotten past that to the email page, it fills out all the fields and all  
i need to do is click the send button on the email page. but when i look  
at it with firebug its completely different than the log on button. i  
put the code in my previous response for the new button.

[Previous page](https://www.ruby-forum.com/t/login-web-page-using-mechanize/224237.md?page=1)
