Every time I access a page for a different stock on the same website one of the buttons that needs to be clicked either has this xpath "//*[@id="content"]/div[1]/div/a[4]" or this xpath "//*[@id="content"]/div[1]/div/a[5]".
If the first xpath doesn't match the stock selected, how can I make it switch to the other xpath, whilst simultaneously not getting a NoneType error?
One of my attempts:
tradebut=browser.find_element_by_xpath('//*[@id="content"]/div[1]/div/a[4]')
tradebut.click()
if tradebut.click() == None:
browser.find_element_by_xpath('//*[@id="content"]/div[1]/div/a[5]').click()
Thanks for the help in advance.
Aucun commentaire:
Enregistrer un commentaire