0

I'm very new to the Selenium module. i try to click the button "המשך" in this site https://www.jumbomail.me/he/ . this is my code:

import time,selenium
from selenium import webdriver

PATH =  r'C:\Program Files (x86)\chrome\chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get('https://www.jumbomail.me/he/')
input_fname=driver.find_element_by_id("tokenfield-tokenfield")
input_fname.send_keys('[email protected]')
input_fname = driver.find_element_by_class_name("send-button jm-button ng-binding ng- scope")

this is the HTML code in the webpage:

<button type="submit" ng-click="vm.submit(false)" class="send-button jm-button ng- 
binding ng-scope" ga-click-event="['Send Form', 'Click', 'Next - Submit button']" 
data-uw-styling-context="true">                        המשך                    
</button>

when i run it, i get this error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable 
to locate element: {"method":"css selector","selector":".send-button jm-button ng- 
binding ng-scope"}
            

2 Answers 2

1

direct click with implicit or Explicit wait does not work, it needs a JS intervention.

Full code :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

PATH =  r'C:\Program Files (x86)\chrome\chromedriver.exe'
driver = webdriver.Chrome(PATH)

driver.maximize_window()
driver.get("https://www.jumbomail.me/he/")
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='סגירה']"))).click()
button = driver.find_element_by_css_selector("button[ng-click='vm.submit(false)']")
driver.execute_script("arguments[0].click();", button)
Sign up to request clarification or add additional context in comments.

Comments

0

You should add a wait to let the elements loaded before accessing them.
Also the submit button המשך can be uniquely located with button tag name and send-button class name while other class names there are not unique and may dynamically change.

import time,selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

PATH =  r'C:\Program Files (x86)\chrome\chromedriver.exe'
driver = webdriver.Chrome(PATH)
wait = WebDriverWait(driver, 20)

driver.get('https://www.jumbomail.me/he/')
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#tokenfield-tokenfield"))).send_keys('[email protected]')
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.send-button"))).send_keys('[email protected]').click()

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.