確認メールを見つけて読むには、スクリプトを調整する必要があります。以下は、電子メールを読むために使用できます。メールの複雑さと受信トレイの内容によっては、いくつかの調整が必要になる場合があります。
verification_link = ''
Gmail.new("sample@registration.com", "111111") do |gmail|
#Get the email the first email that is:
# unread and
# from 'noreply@registration.com'
email = gmail.inbox.emails(:unread, :from => 'noreply@registration.com').first
#Get the message body, which will be in html
message = email.body.decoded
#Parse the message body for the link
# You may need to adjust the regex depending on the complexity of the email
# If the email is very complex, use Nokogiri to parse the html
verification_link = /<a.*?href="(.+?)".*?>Verify Now<\/a>/m.match(message)[1].gsub(/\s/, '')
#=> "http://innovify.in/kwexcui/index.php?r=site/registerFirstSlap/key/3f21f205d603ce83e4dbd4667ff66a1f:2a/id/MTI2ODg2NjM4NTUyNw/lng/eng/email/maulik.goswami@bypeopletechnologies.in/companyName/R09PR0xFIFVLIExJTUlURUQ=/phoneNumber/012345678901234"
end
リンクを「クリック」することはできません。ただし、ブラウザでナビゲートするのと同じである必要があります。つまり、電子メールから抽出されたリンクに移動します。
br = Watir::Browser.new :chrome
br.goto verification_link