Python Forum
Clicking on element not triggering event in Selenium Python (Event Key is not in data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clicking on element not triggering event in Selenium Python (Event Key is not in data
#1
I have a problem of whenever i want to click on an button element it does not trigger the event. In my case I am trying to add an item to the cart. A size needs to be clicked first before clicking the add to cart button. I am using chrome headless browser as well as the webdriver.


 from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import os

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = (r"C:\Users\dkael\AppData\Local\Google\Chrome SxS\Application\chrome.exe")

driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"),   chrome_options=chrome_options)
driver.get("https://www.nike.com/sg/launch/t/react-presto-undercover-white/")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//button[contains(text(),'US 10.5')]"))).click()
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class,'buying-tools-container')]//li[contains(@class,'selected')]")))
element = driver.find_element_by_xpath("//button[@class='ncss-brand ncss-btn-black pb3-sm prl5-sm pt3-sm u-uppercase u-full-width']")
element.send_keys(Keys.ENTER)
driver.save_screenshot("test.png")

print("success")

driver.quit() 
I have tried this as well
 WebDriverWait(driver, 20).until(EC.element_located_to_be_selected((By.XPATH,"//button[@class='ncss-brand ncss-btn-black pb3-sm prl5-sm pt3-sm u-uppercase u-full-width']"))).click() 
I believe the problem is here
"*PROJECT_CONFIG: Event key add-to-cart-clicked is not in datafile.", source: https://c.go-mpulse.net/boomerang/R6SH7-...W6MF-W5RWR*"

Here is the HTML of the button i am trying to click.
https://i.stack.imgur.com/qyXUB.png

Appreciate any input on this matter. Thanks in advance.
Reply


Messages In This Thread
Clicking on element not triggering event in Selenium Python (Event Key is not in data - by dkaeloredo - Feb-14-2020, 03:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium suddenly fails to find element Pavel_47 3 6,304 Sep-04-2022, 11:06 AM
Last Post: Pavel_47
  Python Selenium (Dropdown-) data Robin_at_Cantelli 2 6,199 Dec-29-2021, 03:16 AM
Last Post: ondreweil
  Extract data with Selenium and BeautifulSoup nestor 3 3,914 Jun-06-2020, 01:34 AM
Last Post: Larz60+
  [FLASK] checkbox onclick event Mad0ck 2 4,840 May-14-2020, 09:35 AM
Last Post: Mad0ck
  Error clicking button with selenium julio2000 4 5,341 Jan-06-2020, 10:59 AM
Last Post: julio2000
  Selenium locating an element. JokerTux 3 2,687 Dec-28-2019, 08:50 AM
Last Post: snippsat
  Selenium returning web element instead of desired text newbie_programmer 1 5,187 Dec-11-2019, 06:37 AM
Last Post: Malt
  Selenium get data from newly accessed page hoff1022 2 2,940 Oct-09-2019, 06:52 PM
Last Post: hoff1022
  How to Caputre Data After Selenium Scroll ahmedwaqas92 3 7,095 Aug-18-2019, 12:43 PM
Last Post: ahmedwaqas92
  Unable to access javaScript generated data with selenium and headless FireFox. pjn4 0 2,544 Aug-04-2019, 11:10 AM
Last Post: pjn4

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020