0

I am trying to login on a website using the selenium webdriver in Python 3. First, I need to click the button "Inloggen", after which I need to fill in username and password and than click the (new) button "Inloggen" again.
So, I've tried to locate the first "Inloggen" button (with the code below), and tried to .click() it, but then it raises an error "selenium.common.exceptions.WebDriverException: Message: ", but without message.

from selenium import webdriver

# go to login page and sign in
driver = webdriver.Firefox()
driver.get("https://www.qassa-nl.be/")

driver.find_element_by_xpath("//a[@title='Inloggen']").click()

Secondly, if this works, I can send my login keys using the classic way I guess.

Best,
Tim

1 Answer 1

1

Here is the Answer to your Question:

Here is the working code block which will open the url https://www.qassa-nl.be/, click on button Inloggen, fills up email, fills up password and finally clicks on Inloggen button:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
caps = DesiredCapabilities().FIREFOX
caps["marionette"] = True
driver = webdriver.Firefox(capabilities=caps, firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get("https://www.qassa-nl.be/")
driver.find_element_by_xpath("//div[@id='personal_info']//a[text()='Inloggen']").click()
driver.find_element_by_xpath("//input[@id='login_username']").send_keys("debanjan")
driver.find_element_by_xpath("//input[@id='login_password']").send_keys("debanjan")
driver.find_element_by_xpath("//button[@title='Inloggen']").click()

Let me know if this Answers your Question.

Sign up to request clarification or add additional context in comments.

8 Comments

Hi! Thanks for the suggested answer. Can you explain me why my method didn't work, and yours does? And can it also work with PhantomJS?
@Tim I have simply accessed the url https://www.qassa-nl.be/ through get() method. Now the script will look for an element with xpath as //div[@id='personal_info']//a[text()='Inloggen'] first & click on it. Next, the script will look for an element with xpath as //input[@id='login_username'] & send the text debanjan. Again, the script will look for an element with xpath as //input[@id='login_password'] & send the text debanjan. Finally, the script will look for an element with xpath as //button[@title='Inloggen'] & click it. Thanks
Hmmm, also, after updating the paths, I got an error on the page load timeout: selenium.common.exceptions.WebDriverException: Message: Unrecognised timeout: page load.
Also, I could not really get the first 5 lines of code (imports not included); from the driver.get I already used in the past. Thanks!
@Tim Please don't bother about the first 5 lines. Testers normally try to put in the exe files and Browser exe in Selenium's convenient location within their system which is easily picked up by Selenium. Where as, as I work with multiple versions of exe files and multiple versions of same browser, so I call them explicitly in my code where ever, whenever & whichever version is needed. Thanks
|

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.