Recently, I used selenium to crawl some information on the website. And What I want to do is just clicking 'previous month button'.
So I push 'F12' button on Chrome And find HTML Code like this
So I write code like this
webDriver.find_element_by_css_selector('span.ui-icon ui-icon-circle-triangle-w').click()
But it doesn't work, I changed multiple times changing the code like this
webDriver.find_element_by_css_selector('a.ui-icon ui-icon-circle-triangle-w').click()
webDriver.find_element_by_css_selector('ui-icon ui-icon-circle-triangle-w').click()
webDriver.find_element_by_class_name('ui-icon ui-icon-circle-triangle-w').click()
Any of those don't work. When I tried to use first one of three trial(that is : webDriver.find_element_by_css_selector('a.ui-icon ui-icon-circle-triangle-w').click()), the error pops up like this
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"a.ui-icon ui-icon-circle-triangle-w"}
(Session info: chrome=86.0.4240.198)
I don't know why it doesn't work..
Please help
try using,
webDriver.find_element_by_class_name("ui-icon.ui-icon-circle-triangle-w").click()
whenever you see space in HTML code you should put '.' instead of space while writing with selenium. Also, instead of writing class name just copy paste and replace space with '.' That is lot easier and removes tying errors.