hello one and all,
perhaps you can give me some advice. i basically load a home page using selenium and phantomJS under python 2.7. then i search that page for a link and have selenium click on it using the click() method. which properly runs the href and or javascript under the <a> tag and then goes to the final website for the click.
but i know that there is a redirect in that click and selenium takes me to the final page. which if i were an end user that would be fine. BUT i want to halt selenium at the redirect and view the current_url of the redirect. how can i do that please?
thanx in advance and have a good day, lucas
p.s. here is my code snippet:
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap['phantomjs.page.settings.userAgent'] = (user_agent)
site = webdriver.PhantomJS(desired_capabilities=dcap)
print site.title
print site.current_url
print
elements = site.find_elements_by_xpath('//a')
for i, e in zip(range(len(elements)), elements):
if (e.get_attribute('outerHTML').find('sometexttofind') > -1):
print "%i: %s" % (i+1, e.get_attribute('outerHTML'))
break
e.click() #which runs the java script under the <a> link and goes to the proper page, but there is a redirect in there.
print site.title
print site.current_url
print
site.quit()