Issue
I want to press the Login Button on the site https://www.bet365.com/#/HO/ using selenium, I'm passing the XPATH of the Element that I select from inspect, but it doesnt work
text base HTML:
<divclass="hmMainHeaderRHSLoggedOutWide_Login">Login</div>
XPATH:
/html/body/div[1]/div/div[3]/div[1]/div/div[2]/div[4]/div[3]/div
Myscript.py
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
driver.get('https://www.bet365.com/#/HO/')
TIME_TO_LOAD = 10
try:
element = WebDriverWait(driver, TIME_TO_LOAD).until(
EC.presence_of_element_located(
(By.XPATH, '/html/body/div[1]/div/div[3]/div[1]/div/div[2]/div[4]/div[3]/div'))
)
finally:
driver.quit()
The button of the page that i want to click:
The text base HTML:< div class="hmMainHeaderRHSLoggedOutWide_Login">Login</ div>
Solution
Try the below xpath
"//*[normalize-space(text())='Login']"
Or
"//*[contains(text(),'Login')]"
to click on button
button = driver.find_element(By.XPATH, "//*[contains(text(),'Login')]")
button.click()
Also, provide the more info to understand the question clearly.
Answered By - Akzy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.