0
votes

I'm writing a script in python using the selenium chrome webdriver, and I want to click on a link. The link itself is:

a href="javascript:contentReplace('/cgi-bin/ssol/9PGaiwzaxu43ZaLXZ8mAix/?p%.5Fr%.5Fid=a5UAMSbnZrZMIowCvr5gzh&p%.5Ft%.5Fid=1&tran%.5B1%.5D%.5Fentry=student&tran%.5B1%.5D%.5Ftran%.5Fname=sreg')">Registration/a>

(I took off the opening < of the link elements so as to be able to display the code, not the text, in the browser)

I couldn't locate it using find_element_by_link_text--it kept throwing an error--so I tried using the xpath. I used firebug to get the xpath, and it is: "/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/ul/li/ul/li[10]/a"

But when I do link = driver.find_element_by_xpath("//html/body/table/tbody/tr[2]/td[2]/ta\ ble/tbody/tr[2]/td/ul/li/ul/li[10]/a")

I get an error of "urlopen error [Errno 61] Connection refused"

Not sure what's wrong, since the xpath works in firebug.

1

1 Answers

0
votes

Try

driver.find_element_by_link_text("Registration").click()

Why can't you record the script in Selenium IDE ? It will directly give the xpath to the link when you click on it.

If you want code, then post the link to webpage where you are clicking on that link. So that it will be easy to give answer.