Discussion:
[Cucumber] Gmail Gem - how to click a link in email body Ruby Cucumber
Add Reply
Sandeep Kommineni
2017-09-18 06:00:34 UTC
Reply
Permalink
Raw Message
I have searched the net upside down for this answer, but I can't seem to
find it. I've tried various methods but they aren't working.

Goal: Using ruby cucumber <https://tekslate.com/ruby-cucumber-training/>,
to click a link within an email I have received. Seems simple right?

Using the gmail gem, something like:

When(/^I click the link$/) do(insert code here)

I can get the body of the email back with

mail.inbox.emails(:from => "rubycucumber")do |email|
puts email.html_part.body.decodedend

But how do I navigate to/click the link (which is in A HREF tag when I view
the email body after running step above)?

It seems the gmail gem is really awesome at counting, labeling, marking as
read, etc, but this piece is giving me trouble :(
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chuck van der Linden
2017-09-28 18:08:31 UTC
Reply
Permalink
Raw Message
Post by Sandeep Kommineni
I have searched the net upside down for this answer, but I can't seem to
find it. I've tried various methods but they aren't working.
Goal: Using ruby cucumber <https://tekslate.com/ruby-cucumber-training/>,
to click a link within an email I have received. Seems simple right?
When(/^I click the link$/) do(insert code here)
I can get the body of the email back with
mail.inbox.emails(:from => "rubycucumber")do |email|
puts email.html_part.body.decodedend
But how do I navigate to/click the link (which is in A HREF tag when I
view the email body after running step above)?
It seems the gmail gem is really awesome at counting, labeling, marking as
read, etc, but this piece is giving me trouble :(
So the question is what is your objective in clicking the link?

If you just want to check that the page is there (e.g. that it is not a
404) you could use the NET:http methods (or other gems that do http
requests) to request the url you extract from the link.

If your objective is to open an actual browser, and interact with the page
that the link directs to, then you will need to use a browser driver such
as Watir, Capybara, or Webdriver.. Personally I like the Watir API
better, and since it uses webdriver under the covers you get the same cross
browser support.. A lot of others like Capybara, which is also built on
top of webdriver and for which there are some examples in the Cucumber Book
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
80Vikram
2017-10-23 15:46:53 UTC
Reply
Permalink
Raw Message
Hey Sandeep,

This is Selenium issue and not related to Cucumber.

You can try it out by adding all the test case in single test method
outside cucumber approach.

Regards,
Vikram
Post by Sandeep Kommineni
I have searched the net upside down for this answer, but I can't seem to
find it. I've tried various methods but they aren't working.
Goal: Using ruby cucumber <https://tekslate.com/ruby-cucumber-training/>,
to click a link within an email I have received. Seems simple right?
When(/^I click the link$/) do(insert code here)
I can get the body of the email back with
mail.inbox.emails(:from => "rubycucumber")do |email|
puts email.html_part.body.decodedend
But how do I navigate to/click the link (which is in A HREF tag when I
view the email body after running step above)?
It seems the gmail gem is really awesome at counting, labeling, marking as
read, etc, but this piece is giving me trouble :(
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...