Reputation: 23
Hi I am trying to login to https://rocket-league.com/ using Selenium. I have managed to login successfully using POST request method in BeautifulSoup but now I have to use Selenium because after logging into the website I have to click on a button, which I cannot do using BeautifulSoup.
There is a button in the form that says 'GO' which logins to website once the email and password are correct. I have tried the submit() method but got the following error : javascript error: arguments[0].submit is not a function (Session info: chrome=87.0.4280.88)
from selenium import webdriver
driver_path = r"C:\Users\user\Downloads\chromedriver.exe"
driver = webdriver.Chrome(executable_path=driver_path)
homepage_URL = 'https://rocket-league.com'
driver.get(homepage_URL)
driver.find_element_by_id('acceptPrivacyPolicy').click()
driver.find_element_by_id('header-email').send_keys('email')
driver.find_element_by_id('header-password').send_keys('password')
btn = driver.find_element_by_xpath('/html/body/header/section[1]/div/div[2]/div[1]/form/input[4]')
btn.submit()
Then I tried the click() method but I got a different error: ElementClickInterceptedException: element click intercepted: Element is not clickable at point (1077, 17) (Session info: chrome=87.0.4280.88)
I have successfully logged into the website using BS post method by posting required values to the php form.
data = {'email':'email','password':'password','csrf_token':token,'rememberme':'on','submit':'Go'}
url = 'https://rocket-league.com/functions/login.php'
result = s.post(url,data=data,cookies= cookie)
What should I do?
Upvotes: 1
Views: 818
Reputation: 19989
submit function works only with html form , as login form is a submit in the page it should work.
But when you try the submit action we get the following error:
This because the form field ahs one field with name submit , the button element name is given as "submit"
This is why only click() works .
But for other pages, you can use submit() on any form fields
"Submit is not a function" error in JavaScript
Upvotes: 0
Reputation: 2813
Indeed you were very close in the attempt with selenium. Try this some changes and it will start working -
Maximize the window - sometimes websites are not responsive and by default chrome opens in small window. When selenium locates Go button element it is not in the view and hence the error
Use proper locators or relative xpath. Absolute xpath makes the scripts flaky.
homepage_URL = 'https://rocket-league.com'
driver.get(homepage_URL)
driver.maximize_window()
driver.find_element_by_id('acceptPrivacyPolicy').click()
driver.find_element_by_id('header-email').send_keys('email')
driver.find_element_by_id('header-password').send_keys('password')
btn = driver.find_element_by_xpath('.//input[@value="Go"]')
btn.click()
Output -
Upvotes: 1