0
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
import os

Game_Pin = input('Enter your PIN: ')
NickNAME = input('Enter your nickname: ')
driver = webdriver.Chrome(executable_path=r"C:\WebDriver\bin\chromedriver.exe")

def Enter_Press(driver):
    driver.find_element_by_xpath("//*[contains(text(), 'Enter')]").click()

def OK_GO(driver):
    driver.find_element_by_xpath("//*[@class='btn btn-greyscale join ng-binding']").click()


def Kahoot_Spammer(Game_Pin, NickNAME, driver):
    driver.get('https://kahoot.it/')
    driver.maximize_window() #For maximizing window
    driver.implicitly_wait(2) #gives an implicit wait for 2 seconds

    game_pin = driver.find_element_by_xpath("//*[@id='inputSession']")
    game_pin.send_keys(Game_Pin)
    Enter_Press(driver)

    driver.implicitly_wait(2)
    Name = driver.find_element_by_xpath("//*[@id='username']")
    Name.send_keys(NickNAME)
    OK_GO(driver)




Kahoot_Spammer(Game_Pin, NickNAME, driver)

The program works fine until you get to a certain point. Then selenium cannot click a button. It gives me this error.

selenium.common.exceptions.WebDriverException: Message: unknown error: Element <button type="submit" class="btn btn-greyscale join ng-binding" blocking="" data-functional-selector="join-button-username">...</button> is not clickable at point (1279, 741). Other element would receive the click: <div id="waitOverlay" class="alert-fullscreen valignwrapper" data-functional-selector="wait-overlay" style="opacity: 0.7;">...</div>

Here is the code for the button I am trying to click.

<button class="btn btn-greyscale join ng-binding" type="submit" data-functional-selector="join-button-username" blocking="">            OK, go!          </button>
2

2 Answers 2

1

You can use action class to resolve this exception,

action=ActionChains(driver)
action.move_to_element("Your element").click().build().perform()
Sign up to request clarification or add additional context in comments.

1 Comment

Note for others: I needed to remove build() for this to work for my application.
0

You use implicitly_wait as a wrong way. In selenium implicitly wait is for setting the find duration of all selenium find API, like find_element_by_xxx. Rather than used for waiting page refresh/load complete.

From the error message we can know, when you click on the Go button, but another element (A layer display loading which at top of the GO button ) received the click event.

So you need to wait the loading layer disappear before click anything covered by it.

Enter_Press(driver)

// driver.implicitly_wait(2) 
// remove above 'implicitly_wait' line, 
// you set the find duration to 2 seconds, the default value is 10 seconds. 
// we don't recommend to change this default value, unless you are doing 
// performance testing to expect the element comes out on page in short time.
// Selenium will return the find result once it found before 10 seconds, 
// otherwise throw `NoSuchElementException` if exceed 10 seconds.

diver.wait(xxx) // or simply use sleep() to wait the `loading` disappear.

Name = driver.find_element_by_xpath("//*[@id='username']")
Name.send_keys(NickNAME)
OK_GO(driver)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.