1
votes

hello i am trying to login in website https://golden77.com but can not login it give following error

selenium.common.exceptions.ElementClickInterceptedException: Message: Element <button class="btn btn-primary ml-2"> is not clickable at point (1278,72) because another element <div id="login" class="modal fade show modal-login-new"> obscures it.

This is my code:- from seleniumwire import webdriver from selenium.webdriver.common.keys import Keys from time import sleep from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC

options=webdriver.FirefoxOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--ignore-certificate-errors')

driver = webdriver.Firefox(executable_path='geckodriver.exe',firefox_options=options)
driver.get("https://golden77.com")
# print(driver.requests)
sleep(10)
sleep(50)
btn_login = driver.find_element_by_xpath("//button[@class='btn btn-primary ml-2']") #<button class="btn btn-primary ml-2">Login</button>
btn_login.click()
sleep(10)
username = driver.find_element_by_xpath("//input[contains(@class,'form-control')][@placeholder='Enter Username']")
username.send_keys("username")
sleep(20)
password = driver.find_element_by_xpath("//input[contains(@class,'form-control')][@placeholder='Enter Password']")
password.send_keys("password")
sleep(3)
try:
    checkbox=driver.find_element_by_class_name("custom-control-label")
    checkbox.click() #check the checkbox
except:
    pass
sleep(10)


lg_btn = driver.find_element_by_xpath("//button[@class='btn btn-primary ml-2']") # login button 
prop = lg_btn.get_property("disabled")
print(prop)
lg_btn.click

i also tried

driver.execute_script("arguments[0].click()",lg_btn)

(This code not giving error and not logging me in) referer actual webpage code of https://golden77.com and help me!

1

1 Answers

0
votes

two issue you have right now in your code.

  1. The class that you are using for check box has 3 web element. So it will click on first element.

  2. When you are actually clicking on login button in the alert pop up, you are not using the right login web element locator.

Fix issue 1 :

try:
    checkbox=driver.find_element_by_id("customCheck")
    checkbox.click() #check the checkbox
except:
    pass

Fix issue 2 :

Instead of this :

lg_btn = driver.find_element_by_xpath("//button[@class='btn btn-primary ml-2']")

Use this :

 lg_btn = driver.find_element_by_xpath("//button[@type='submit']")

Update 1 :

driver = webdriver.Chrome("C:\\Users\\Desktop\\Selenium+Python\\chromedriver.exe")
driver.maximize_window()
wait = WebDriverWait(driver, 30)
driver.get("https://golden77.com")
# print(driver.requests)
btn_login = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Login']"))) #<button class="btn btn-primary ml-2">Login</button>
btn_login.click()
username = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "label.user-email-text+input[type='text']")))
username.send_keys("username")
password = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "label.user-email-text+input[type='password']")))
password.send_keys("password")
driver.execute_script("document.getElementsByName('example1')[0].click();")
lg_btn = driver.find_element_by_xpath("//button[@type='submit']") # login button
prop = lg_btn.get_property("disabled")
print(prop)
lg_btn.click()