Using Selenium with Python to log in via a pop-up interface

Currently, I am attempting to log into a certain website using Python 3's selenium webdriver. To start the login process, I first have to click on the "Inloggen" button. Following that, I need to enter my username and password before clicking on the new "Inloggen" button once again.
After trying to locate the initial "Inloggen" button with the provided code below, an error was thrown stating "selenium.common.exceptions.WebDriverException: Message:", unfortunately no message was provided.

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()

If this initial step is successful, I can proceed to submit my login credentials through the usual method.

Sincerely,
Tim

Answer №1

Thank you for your question!

Below is the code snippet that demonstrates how to automate logging in to the website "https://www.qassa-nl.be/":

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()

If this solution resolves your query, please let me know.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking to implement a way to press "ALT+T" in Selenium WebDriver using Java? This method can be used to seamlessly switch between tabs while browsing

When attempting to use the code below, an error occurs stating "Cannot focus on element". Any assistance would be greatly appreciated. String selectAll = Keys.chord(Keys.ALT,"T"); driver.findElement(By.tagName("html")).sendKeys(selectAll); ...

What could be causing selenium-webdriver (LiveServerTestCase) to continue connecting to the incorrect database?

When running integration tests for a Django app using Selenium (and the postgres database in development), I encountered an issue. The setup involved creating a Model object, with tests interacting through the browser (selenium-webdriver) or directly via ...

Comparing the use of sleep and explicit wait in Selenium with Python

I have been working on scraping flight information by airport, and here is a snippet of my code: import time from selenium import webdriver from selenium.common import NoSuchElementException, StaleElementReferenceException from selenium.webdriver.common.by ...

Inserting data into MSSQL using Python and pypyodbc requires parameters to be organized in either a list or tuple

I'm currently working on writing values to a MSSQL instance. Here's the code snippet I have so far: import pypyodbc lst = ['val1', 'val2', 'val3'] connection = pypyodbc.connect(...) cursor = connection.cursor() curs ...

What is the best way to execute a JavaScript function using Python Selenium?

Is it possible to repeatedly call the MapITRFtoWgs84() function with input from a text file and save the output to another text file? I believe Selenium might be the right tool for this task. Could you provide guidance on how to achieve this? Attached is ...

Using Selenium to retrieve a list of elements located between two h1 elements

I'm currently working on a webpage that includes the following HTML snippet: <h1> ... </h1> <p> ... </p> <p> ... </p> <h1> ... </h1> <h2> ... </h2> <p> ... </p> <h3> ... &l ...

Leveraging Python CDK to package .NET 8 code into an AWS Lambda function

My current project involves using CDK with Python to develop, package, and deploy .NET 8 code as a lambda function. The Python script I am working on encounters the following error message: Error: .NET binaries for Lambda function are not correctly instal ...

What is the best way to structure collected data for incorporation into Bayesian networks within the pymc3 framework?

I've been grappling with the concept of observed data in pymc3 and have come across some helpful examples that got me part of the way there, but I'm still struggling to make my model work. One example involves using customer records from a restau ...

Learn how to interact with keyboard buttons without directly sending keys to a search box. Simply utilize the Keys.PAGE_DOWN method instead of manually sending keys using searchbox.send_keys(Keys.PAGE_DOWN)

How can I use the Python Selenium module to simulate pressing buttons on the keyboard without sending keys directly to a search box? I want to be able to scroll through an Instagram feed by using Keys.PAGE_DOWN, but when I send keys to the search box, it t ...

Checking off all the boxes on the registration form

I am encountering an issue while attempting to select all check-boxes on the registration form. The error message displayed is org.openqa.selenium.NoSuchElementException. Below is the code snippet that I have tested: public class SelectCheckboxes { ...

Encountered a problem while attempting to import VideoFileClip from moviepy: AttributeError was raised stating that the object of type 'PermissionError' does not have an attribute called 'message

I am utilizing the jupyter notebook platform, and I have also attempted to run it from the anaconda console. I tried importing using both methods displayed below: from moviepy.editor import VideoFileClip from moviepy.video.io.VideoFileClip import VideoFi ...

What is the method for retrieving individual items from an array stored within a dictionary?

Suppose there is an array of strings saved in a dictionary, and I want to retrieve the first element from that array. What steps should I take to achieve this? Here is the code snippet I have already written... public IC2Engineering GetReportResultsTable ...

Using Selenium to execute drag and drop actions in Chrome even when element identifiers are not available

For what feels like an eternity, I've been scouring the depths of the internet in search of a solution... I'm facing a challenge with trying to replicate a drag and drop action in Chrome using Selenium WebDriver. While this process works seamles ...

How can Selenium best handle the challenge of waiting for elements that may not always be present?

Consider this scenario: <div id='parent'> <div class='profile-pic'>...</div> <p class='email'>I'm not always present</p> <span class='name'>John Smith</span> </ ...

In the multiindex pandas, which month shows the greatest total accumulation?

I am currently working with a pandas dataframe that has a MultiIndex structure: chamber_temp month day 1 1 0.000000 2 0.005977 3 0.001439 4 -0.000119 5 0.000514 ... 12 27 0.00 ...

Keypress functionality disabled on password input field

While I am able to successfully fill in the password field using the sendkeys method, I am encountering an issue when trying to press the ENTER button. Even though no exception is raised, the command seems to be ineffective. What could be causing this pr ...

Unable to automate the selection of a dropdown menu using Selenium WebDriver

I am currently utilizing http://www.makemytrip.com/ This is the HTML code. <div class="mrgnBot30 clearFix"> <span class="watch_icn flL"></span> <div class="widget_inner clearFix suggest_me padBot15 flL"> <h3 class="clearFix has ...

Utilizing Selenium WebDriver in combination with Chrome to locate elements using XPath and programming in Java

During my automation test, I observed that the findElementByXPath function works well on Firefox but returns undefined on Chrome. I am in search of an alternative method or class that would function correctly on Chrome like it does on Firefox. action.mo ...

Unable to use sendKeys(Keys.TAB) in JMeter Webdriver Sampler for tab navigation issue

Currently, I am facing an issue where I am attempting to input a value into a textfield and then press Tab to move on to the next field. However, the Keys.TAB method does not seem to be functioning as expected. Below is my code snippet: var Keys = JavaIm ...

Tips for verifying the inputted text in a search box with Selenium in Node.js and Mocha chai

Looking to perform validation on the string entered into the "Google search box" Upon running the following code in Node.js, an error is encountered: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. Below is th ...