Is there a way to click on specific anchor tags with href BUT only with specific css selectors/text/tags/etc?
This is the link which I want to click through: http://www.oddsportal.com/soccer/germany/bundesliga/
NOTE: The table is table#tournamentTable.table-main, the one in the middle.
There is a table and I would like to click in each link displayed. (I already know there's something called 'is_displayed' but I haven't arrived to this issue yet so this is not the main problem)
The problem is that, as far as I have tried, I haven't figured out how to click only on the ones which I want! (Which have a unique css selector)
Here is my current code (I will point out where I am struggling):
#Load Modules
from selenium import webdriver
from time import sleep
from random import randint
#Set profile
profile = webdriver.FirefoxProfile()
profile.set_preference("Set Profile")
#Open driver
driver = webdriver.Firefox(profile)
driver.get("http://www.oddsportal.com/soccer/germany/bundesliga/")
#Find the elements (FIRST IDEA)
list_links=driver.find_elements_by_css_selector(".name.table-participant")
"""
These ones are not clickable BUT this is the list that I want.
"""
#Print
for i in list_links:
print(i.text)
#(SECOND IDEA)
list_links=driver.find_elements_by_partial_link_text('-')
"""
Pretty close I guess, but there are still some
elements that I don't want
"""
#Print
for i in list_links:
print(i.text)
#(THIRD IDEA(S)) None of them works
list_links=driver.find_elements_by_xpath("//a[contains(text(),'/bundesliga/')]")
list_links=driver.find_element_by_xpath('//a[@href=soccer/germany/bundesliga/]')
list_links=driver.find_elements_by_css_selector(".name.table-participant[class='href']")
"""
I guess I'm pretty close but I can't get the click!
"""
#Print
for i in list_links:
print(i.text)
#End
By the way, I stumbled upon with this: selenium click on anchor tag inside table td
I know is something related to xpath but...how to combine xpath which includes specific css selectors and also the anchor clickable tags?
Any thoughts?
table#tournamentTable.table-main