How can I click on random link on a given webpage using selenium API for python. ? I'm using python 2.7. Thanks
find_elements_by_tagname() will surely work. There is another option also. You can use find_elements_by_partial_link_text where you can pass empty string.
>>> from selenium import webdriver
>>> from random import randint
>>> driver = webdriver.Firefox()
>>> driver.get('http://www.python.org')
>>> links = driver.find_elements_by_partial_link_text('')
>>> l = links[randint(0, len(links)-1)]
>>> l.click()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With