I want to locate the "NEXT" button. Locating by class name is not working because there is other element with the same class name. This button has no ID.
I tried locating by xpath>>contains text etc and it works. But it's not the perfect way, due to possible future translation of the site and the "NEXT" text may seem quite another... It is about 2 last lines.
https://i.stack.imgur.com/7YbPK.jpg
from time import sleep
import self as self
from selenium import webdriver
from selenium.common.exceptions import ElementClickInterceptedException, StaleElementReferenceException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path="C:\Chromedriver\chromedriver.exe")
driver.implicitly_wait(1)
driver.get("https://cct-103.firebaseapp.com/")
try:
checkin = WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CLASS_NAME, "MuiButton-label")))
checkin.click()
except StaleElementReferenceException:
checkin = WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CLASS_NAME, "MuiButton-label")))
checkin.click()
locator = (By.ID, "guestName")
guest_input = driver.find_element(*locator)
guest_input.send_keys("xyz")
next_button = driver.find_element_by_xpath("//*[contains(text(), 'NEXT')]")
next_button.click()