Issue
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"}
Solution
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)
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.