This is the link "https://www.airtel.in/" once you entered, please click "PAY & RECHARGE" then you will have Recharge option.
On Tuesday, March 28, 2017 at 9:34:08 AM UTC-7, Titus Fortner wrote: > > Apparently you included the link in an earlier post that I missed. It does > look like Watir is grabbing a different, hidden element. I'll try to take a > longer look at it tonight. > > Titus > > On Tuesday, March 28, 2017 at 11:24:16 AM UTC-5, Raja gopalan wrote: >> >> hi, sorry, that was not done properly, here is the html file >> >> <section id="mega-menu-pay-recharge" class="mega-menu-container >> mega-menu-pay-recharge mega-menu-open"> >> <a class="mega-menu-close close" href="javascript:void(0);"> >> <article> >> <div class="mega-dropdown-menu"> >> <!-- ==== Label 2 Menu || Sub Menu for Pay and recharges ==== --> >> <ul> >> <li> >> <li> >> <li class="link-active"> >> <a module-id="common" data-i18n="recharge" href="javascript:void(0);"> >> Recharge</a> >> <!-- ==== Label 3 Menu || Sub Menu for Recharge ==== --> >> <ul> >> </li> >> <li> >> </ul> >> </div> >> </article> >> </section> >> <!-- mega-menu-pay-recharge End--> >> <!-- mega-menu-get--> >> >> On Monday, March 27, 2017 at 9:32:57 PM UTC-7, Titus Fortner wrote: >>> >>> This html doesn't have any links with text equal to "Recharge" >>> >>> >>> On Monday, March 27, 2017 at 11:13:03 PM UTC-5, Raja gopalan wrote: >>>> >>>> Here is the Html code >>>> >>>> <document> >>>> <html> >>>> <head> >>>> <body> >>>> <main> >>>> <div class="content-wrap"> >>>> <!--Header--> >>>> <header> >>>> <nav id="airtelMegaMenu" class="navbar navbar-default dropdown"> >>>> <div class="container-fluid text-right top-smal-menu"> >>>> <div class="container-fluid large-menu"> >>>> <!-- ==== Label 2 Menus for desktop ==== --> >>>> <!-- mega-menu-pay-recharge --> >>>> <section id="mega-menu-pay-recharge" class="mega-menu-container >>>> mega-menu-pay-recharge mega-menu-open"> >>>> <a class="mega-menu-close close" href="javascript:void(0);"> >>>> <article> >>>> <div class="mega-dropdown-menu"> >>>> <!-- ==== Label 2 Menu || Sub Menu for Pay and recharges ==== --> >>>> <ul> >>>> <li> >>>> <li class="link-active"> >>>> <a module-id="common" data-i18n="pay_bill" href="javascript:void(0);"> >>>> Pay Bill</a> >>>> <!-- ==== Label 3 Menu || Sub Menu for Pay bill ==== --> >>>> <ul> >>>> </li> >>>> <li class=""> >>>> <li class=""> >>>> </ul> >>>> </div> >>>> </article> >>>> </section> >>>> <!-- mega-menu-pay-recharge End--> >>>> <!-- mega-menu-get--> >>>> <section id="mega-menu-get" class="mega-menu-container mega-menu-get"> >>>> <!-- mega-menu-get --> >>>> <!-- mega-menu-BANK WITH US--> >>>> <section id="mega-menu-bank" class="mega-menu-container mega-menu-bank" >>>> > >>>> <!-- mega-menu-BANK WITH US--> >>>> <!-- ==== Label 2 Menus for desktop ==== --> >>>> <!-- ==== Label 2 Menus for Mobile ==== --> >>>> <!-- Mobile mega menu--> >>>> <div id="mobile-mega-menu"> >>>> <!-- mega-menu-Bank-mobile --> >>>> <section id="mega-menu-pay-recharge" class="mega-menu-container >>>> mega-menu-bank-mobile"> >>>> <a class="mega-menu-close back visible-sm visible-xs" href=" >>>> javascript:void(0);"> >>>> <article> >>>> <div class="mega-dropdown-menu"> >>>> <ul> >>>> <li> >>>> <li class="link-active"> >>>> <a module-id="common" data-i18n="savings_account" href=" >>>> javascript:void(0);">Savings Account</a> >>>> <ul> >>>> </li> >>>> <li> >>>> </ul> >>>> </div> >>>> </article> >>>> </section> >>>> <!-- mega-menu-Bank-mobile--> >>>> <!-- mega-menu-pay-bill-mobile --> >>>> <section class="mega-menu-container mega-menu-pay-bill"> >>>> <section class="mega-menu-container mega-menu-recharge"> >>>> <!-- mega-menu-pay-bill-mobile End--> >>>> <!-- mega-menu-Add-money --> >>>> <section class="mega-menu-container mega-menu-add-money"> >>>> <!-- mega-menu-Add-money End--> >>>> <!-- mega-menu-Get for me--> >>>> <section class="mega-menu-container mega-menu-get-for-me"> >>>> <!-- mega-menu-Get for me End--> >>>> <!-- mega-menu-for-home-mobile --> >>>> <section class="mega-menu-container mega-menu-get-for-home"> >>>> <!-- mega-menu-for-home-mobile End--> >>>> <!-- mega-menu-exciting-offers-mobile --> >>>> <section class="mega-menu-container mega-menu-exciting-offers"> >>>> <!-- mega-menu-exciting-offers-mobile End--> >>>> <!-- mega-menu-Bank with us mobile --> >>>> <section class="mega-menu-container mega-menu-savings-account"> >>>> <!-- mega-menu-Bank with us mobile End--> >>>> <!-- mega-menu-money-wallet mobile --> >>>> <section class="mega-menu-container mega-menu-money-wallet"> >>>> <!-- mega-menu-money-wallet mobile End--> >>>> </div> >>>> <!--Mobile mega menu--> >>>> <!-- ==== Label 2 Menus for Mobile End==== --> >>>> </nav> >>>> </header> >>>> <div itemtype="http://schema.org/WebSite" itemscope=""> >>>> <section class="banner padding-top-0 padding-bottom-0 airtel-app >>>> bg-white home-banner overflow-hidden airtelwow animated"> >>>> <div class="airtelwow animated"> >>>> <div class="flex-container airtelwow"> >>>> <div class="flex-container bg-white airtelwow"> >>>> <div class="airtelwow"> >>>> <div class="flex-container bg-white airtelwow"> >>>> <div class="flex-container bg-white airtelwow"> >>>> <!--footer--> >>>> <footer> >>>> </div> >>>> </main> >>>> <script async="" src=" >>>> app/libs/edited/homepage/airtel-jqlite.js?version=1490500432236"/> >>>> <script async="" src=" >>>> app/libs/edited/homepage/lazyloading.js?version=1490500432236"/> >>>> <script type="text/javascript">var _gaq = _gaq || []; >>>> _gaq.push(['_setAccount', 'UA-35987772-1']); >>>> _gaq.push(['_setDomainName', 'airtel.in']); >>>> _gaq.push(['_setAllowLinker', true]); >>>> _gaq.push(['_setAllowAnchor', true]); _gaq.push(['_addIgnoredRef', >>>> ' >>>> airtel.in']); _gaq.push(['_trackPageview']); (function() { >>>> var ga = document.createElement('script'); ga.type = >>>> 'text/javascript'; ga.async = true; >>>> //ga.src = ('https:' == document.location.protocol ? 'https://' : >>>> 'http://') + ' >>>> stats.g.doubleclick.net/dc.js'; >>>> ga.src = ('app/libs/edited/homepage/dc.js?version=1490500432236'); >>>> var s = document.getElementsByTagName('script')[0]; >>>> s.parentNode.insertBefore(ga, s); >>>> })();</script> >>>> <script type="text/javascript"/> >>>> </body> >>>> </html> >>>> </document> >>>> >>>> On Monday, March 27, 2017 at 2:13:16 PM UTC-7, Titus Fortner wrote: >>>>> >>>>> I'd need to see the html to see why it works for one of the locator >>>>> strategies, but not the other. >>>>> >>>>> On Mon, Mar 27, 2017 at 1:21 PM, Raja gopalan <[email protected]> >>>>> wrote: >>>>> >>>>>> Here is the code >>>>>> >>>>>> >>>>>> >>>>>> require 'watir' >>>>>> class AirTelRecharge >>>>>> def initialize >>>>>> caps = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: >>>>>> false) >>>>>> @b=Watir::Browser.new :firefox, desired_capabilities: caps, profile: >>>>>> "default" >>>>>> @b.goto "https://www.airtel.in/" >>>>>> @[email protected] >>>>>> @driver.manage.timeouts.implicit_wait=10 >>>>>> end >>>>>> >>>>>> def execute >>>>>> @b.element(:text, 'Pay & Recharge').click >>>>>> @driver.find_element(:link,'Recharge').click #Here is the problem >>>>>> this code doesn't work for @b.element(:text,'Recharge').click >>>>>> end >>>>>> end >>>>>> >>>>>> AirTelRecharge.new.execute >>>>>> >>>>>> >>>>>> >>>>>> On Monday, March 27, 2017 at 8:48:37 AM UTC-7, Titus Fortner wrote: >>>>>>> >>>>>>> Those two locators should find the same element, but it appears it >>>>>>> is not if one says the element exists but is not visible and the other >>>>>>> says >>>>>>> it is visible. To figure out why it is finding a different element, I'd >>>>>>> need to see the underlying html. >>>>>>> >>>>>>> >>>>>>> On Sunday, March 26, 2017 at 11:38:52 PM UTC-5, Raja gopalan wrote: >>>>>>>> >>>>>>>> Link is clearly visible to click >>>>>>>> >>>>>>>> If I write >>>>>>>> >>>>>>>> @b.link(:text,'Recharge').click >>>>>>>> >>>>>>>> WATIR converts this code into >>>>>>>> >>>>>>>> @driver.find_element(:xpath,"//a[normalize-space()='Recharge']"). >>>>>>>> click >>>>>>>> >>>>>>>> but this selenium code says that element is not visible, So it's >>>>>>>> not working. >>>>>>>> >>>>>>>> If I write the following selenium code >>>>>>>> >>>>>>>> @driver.find_element(:link,'Recharge').click >>>>>>>> >>>>>>>> It works properly. >>>>>>>> >>>>>>>> Do you understand me now? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Sunday, March 26, 2017 at 3:05:51 PM UTC-7, Titus Fortner wrote: >>>>>>>>> >>>>>>>>> Is Watir finding a different link? Or is Selenium just allowing >>>>>>>>> the user to click a link that is not displayed? >>>>>>>>> >>>>>>>>> There are definitely ways that Watir can optimize its locator >>>>>>>>> strategies, but that part of the code is not trivial to dig into. As >>>>>>>>> always, pull requests are welcome. >>>>>>>>> >>>>>>>>> On Sun, Mar 26, 2017 at 12:18 PM, Raja gopalan < >>>>>>>>> [email protected]> wrote: >>>>>>>>> >>>>>>>>>> >>>>>>>>>> I have written the following selenium code to click this link >>>>>>>>>> >>>>>>>>>> @driver.find_element(:link,'Recharge').click >>>>>>>>>> >>>>>>>>>> It successfully clicks the line >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I have written the same code in WATIR as shown below >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> @b.link(:text,'Recharge').click >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> but it throws element not present error >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I checked out how this above code works, this above code forms this >>>>>>>>>> xpath at the end >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> "//a[normalize-space()='Recharge']" >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> So I suspected that this xpath might be the reason, So I have >>>>>>>>>> written the below selenium code using this xpath, As I expected the >>>>>>>>>> same >>>>>>>>>> error was >>>>>>>>>> >>>>>>>>>> thrown by selenium as well(element is not visible) >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> @driver.find_element(:xpath,"//a[normalize-space()='Recharge']").click >>>>>>>>>> >>>>>>>>>> So what I think is, WATIR should refrain forming the xpath when >>>>>>>>>> b.link is called, they can directly convert this code to >>>>>>>>>> @driver.find_element(:link,'Recharge') but they >>>>>>>>>> >>>>>>>>>> can form the xpath when b.element(:text,'Recharge') is called >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> any suggestion? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> -- >>>>>>>>>> Before posting, please read http://watir.com/support. In short: >>>>>>>>>> search before you ask, be nice. >>>>>>>>>> >>>>>>>>>> [email protected] >>>>>>>>>> http://groups.google.com/group/watir-general >>>>>>>>>> [email protected] >>>>>>>>>> >>>>>>>>>> --- >>>>>>>>>> You received this message because you are subscribed to the >>>>>>>>>> Google Groups "Watir General" group. >>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>>>> send an email to [email protected]. >>>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>> -- >>>>>> Before posting, please read http://watir.com/support. In short: >>>>>> search before you ask, be nice. >>>>>> >>>>>> [email protected] >>>>>> http://groups.google.com/group/watir-general >>>>>> [email protected] >>>>>> >>>>>> --- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Watir General" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
