0

I am trying to work with the following site using Python. Please advise how can I hit the Next button:

enter image description here

I have tried the following:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.common.action_chains import ActionChains
import time

driver = webdriver.Chrome(executable_path = r'C:/chromedriver.exe')
driver.maximize_window()

wait = WebDriverWait(driver,40)

driver.get('https://www.okcupid.com/login')

driver.execute_script('arguments[0].click();',wait.until(EC.element_to_be_clickable((By.ID, 'username'))))
wait.until(EC.element_to_be_clickable((By.ID, 'username'))).send_keys("abc")

driver.execute_script('arguments[0].click();',wait.until(EC.element_to_be_clickable((By.ID, 'username'))))
wait.until(EC.element_to_be_clickable((By.ID, 'password'))).send_keys("123")

# Find login button
login_button = driver.find_element_by_name('Next')
# Click login
login_button.click()

But got an error:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="Next"]"}

1 Answer 1

1

Name is a an attribute on a webelement. The next button has no Name attribute.

You can try this xpath:

//input[@value='Next']

login_button = driver.find_element_by_xpath('//input[@value="Next"]')
Sign up to request clarification or add additional context in comments.

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.