When I use Selenium I can't use XPATH for this object because it's dynamic or something it can sometimes find it and sometimes not. I would use By.CLASS_NAME
but when I do it says that the object could not be found and used the method css_selector
. When I do use the CSS selector, it can't find it too.
Yes, I used the web browser on the exact site to verify they are correct. Yes, I tried every possible method, including XPATH. Yes, I did research and could not find anything.
Here's the CSS selector:
#app-mount > div.appAsidePanelWrapper-ev4hlp > div.notAppAsidePanel-3yzkgB > div.app-3xd6d0 > div > div > div > form > div.centeringWrapper-dGnJPQ > div > div:nth-child(7) > button
Here's the class name:
button-1cRKG6 button-ejjZWC lookFilled-1H2Jvj colorBrand-2M3O3N sizeLarge-2xP3-w fullWidth-3M-YBR grow-2T4nbg
Here's the code with css selector:
driver.find_element(By.CSS_SELECTOR, "#app-mount > div.appAsidePanelWrapper-ev4hlp > div.notAppAsidePanel-3yzkgB > div.app-3xd6d0 > div > div > div > form > div.centeringWrapper-dGnJPQ > div > div:nth-child(7) > button").click()
Returning:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"#app-mount > div.appAsidePanelWrapper-ev4hlp > div.notAppAsidePanel-3yzkgB > div.app-3xd6d0 > div > div > div > form > div.centeringWrapper-dGnJPQ > div > div:nth-child(7) > button"}
Here it is with the class name:
driver.find_element(By.CLASS_NAME, "button-1cRKG6 button-ejjZWC lookFilled-1H2Jvj colorBrand-2M3O3N sizeLarge-2xP3-w fullWidth-3M-YBR grow-2T4nbg").click()
Returning:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".button-1cRKG6 button-ejjZWC lookFilled-1H2Jvj colorBrand-2M3O3N sizeLarge-2xP3-w fullWidth-3M-YBR grow-2T4nbg"}
(Notice how it says {"method":"css selector"
)