I'm trying to add a repetitive text response to a chat box in a gaming website in order to create an algorithm which guesses words based on a drawing and hint.
The website is the popular pictionary website : https://skribbl.io/
I've been working on the algorithm to guess the words based on others reply, I'm not familiar with Selenium and trying to just print some simple text in the chat/guess textbox.
The website opens up, but it's not printing anything onto the box. How can I resolve this ? Thank you
from selenium import webdriver
from selenium.webdriver.support import ui
from selenium.webdriver.common.keys import Keys
def page_is_loaded(driver):
return driver.find_element_by_tag_name("body")!=None
driver = webdriver.Firefox(executable_path = 'C:\Program Files\gecko\geckodriver.exe')
driver.get("https://skribbl.io/?p0YRvXqupiza")
wait = ui.WebDriverWait(driver,10)
wait.util(page_is_loaded)
for x in range (0,20):
textbox = driver.find_element_by_name("text")
textbox.send_keys("1")
This is how the homepage of Skribbl.io looks like - https://i.sstatic.net/6j0Jg.jpg
The textbox is seen at the bottom right-hand side where I want the input from my code can be found here - https://i.sstatic.net/lLazo.jpg
Try the following
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
firefox_browser = webdriver.Firefox(executable_path=r'C:\Program Files\gecko\geckodriver.exe')
firefox_browser.get("https://skribbl.io/")
time.sleep(2)
name_input = firefox_browser.find_element_by_css_selector("#inputName")
play_button = firefox_browser.find_element_by_css_selector("button.btn:nth-child(3)")
name_input.send_keys("Drums3")
play_button.send_keys(Keys.ENTER)
for x in range(0, 20):
time.sleep(3)
chat_input = firefox_browser.find_element_by_css_selector("#inputChat")
chat_input.send_keys("hello")
chat_input.send_keys(Keys.ENTER)