@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.
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscribe@googlegroups.com
---
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 watir-general+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@b.link(:text,'Recharge').click
@driver.find_element(:xpath,"//a[normalize-space()='Recharge']").click
@driver.find_element(:link,'Recharge').click
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 <rajagopa...@gmail.com> wrote:
I have written the following selenium code to click this link
@driver.find_element(:link,'Recharge').clickIt successfully clicks the lineI have written the same code in WATIR as shown below
@b.link(:text,'Recharge').clickbut it throws element not present errorI 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 wasthrown by selenium as well(element is not visible)
@driver.find_element(:xpath,"//a[normalize-space()='Recharge']").clickSo 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 theycan form the xpath when b.element(:text,'Recharge') is calledany suggestion?
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
---
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 watir-genera...@googlegroups.com.
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/"
@driver=@b.driver
@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
---
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 watir-general+unsubscribe@googlegroups.com.
<a class="mega-menu-link" data-mega-menu="recharge" href="javascript:void(0);">Recharge</a>
<a href="javascript:void(0);" data-i18n="recharge" module-id="common">Recharge</a>
<a target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank WithUs> Savings Account > Manage Account > Recharge')">Recharge</a>
<a target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank WithUs> Wallet > Transact > Recharge')">Recharge</a>
<a target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank WithUs> Savings Account > Manage Account > Recharge')">Recharge</a>
<a target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common" onclick="setCookie('headerlink','Bank WithUs> Wallet > Transact > Recharge')">Recharge</a>
<a onclick="setCookie('headerlink','Savings Account > Transact > Recharge')" target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common">Recharge</a>
<a onclick="setCookie('headerlink','Wallet > Transact > Recharge')" target="_self" href="https://www.airtel.in/netbanking/payments-recharges" data-i18n="recharge" module-id="common">Recharge</a>
b.links(:text, 'Recharge').map(&:visible?)
#=> [false, true, false, false, false, false, false, false]
b.link(text: 'Recharge', visible: true).click
The difference appears to be that `b.link(:text, 'Recharge')` includes hidden links, where as `driver.find_element(:link, 'Recharge')` only includes visible links.
b.link(:text,'Recharge')
driver.find_element(:link,'Recharge')
b.element(:text,'Recharge')
driver.find_element(:xpath,"//*[normalize-space()='Rechage']")
b.element(:link,'Recharge').click
b.element(:link,'Recharge').click
if WD_FINDERS.include?(how)
how, what = @selector.to_a.first
selector_builder.check_type(how, what)
if WD_FINDERS.include?(how)
wd_find_first_by(how, what)
else
find_first_by_multiple
end