Fill Username and Password Using Selenium in Python

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:32:40

3K+ Views

We can fill username and password fields in a login page with Selenium. This is considered an authentication step for any application. Once the username and password is entered, we have to click the login button.ExampleCode Implementation.import time from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") driver.get("https://mail.rediff.com/cgi-bin/login.cgi") # identify username, password and signin elements driver.find_element_by_name("login").send_keys("tutorialspoint") time.sleep(0.2) driver.find_element_by_name("passwd").send_keys("pass123") time.sleep(0.4) driver.find_element_by_class_name("signinbtn").click() driver.closeIf a valid username and password is provided, we shall be directed to the home page of the application.OutputRead More

Test If Element Is Present Using Selenium WebDriver

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:31:00

4K+ Views

We can verify if an element is present using Selenium. This can be determined with the help of findElements() method. It returns the list of elements matching the locator we passed as an argument to that method.In case there is no matching element, an empty list [having size = 0] will be returned. We are not using the findElement() method since if there is no matching element, this method gives NoSuchElementException.In an event of any exception, we have to handle it with a try catch block.ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class ... Read More

Take Partial Screenshot of Frame with Selenium WebDriver

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:27:47

639 Views

Whenever we encounter a failure during testing, it is a common nature to capture the screenshots wherever there is a deviation from the expected result. Thus it is considered a mandatory step to attach a screenshot for creating a bug.While automating a bunch of test cases of a considerable number, capturing screenshot is critical to infer why a test case has failed for both the development and testing team. As they debug the failures, going through the screenshot and conclude if the failure is due to script issue or defect in the application.Sometimes we may need to capture the screenshot ... Read More

Automate Drag and Drop Functionality Using Selenium WebDriver in Java

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:25:06

684 Views

The drag and drop action is done with the help of a mouse. It happens when we drag and then place an element from one place to another. This is a common scenario when we try to move a file from one folder to another by simply drag and drop action.Selenium uses the Actions class to perform the drag drop action. The dragAndDrop(source, destination) is a method under Actions class to do drag and drop operation. The method will first do a left click on the element, then continue the click to hold the source element. Next it shall move ... Read More

Perform Mouseover Function in Selenium WebDriver Using Java

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:20:57

856 Views

A mouse hover is done on an element to fire an event on that element. If we hover on the menus of a webpage the submenus appears. Thus this event gets triggered on hovering on an element.It is evident from the above image that on hovering over the Packages menu the color of the text changed along with the tooltip display. Selenium has the Actions class that contains multiple APIs for mouse cursor movement.The moveToElement() method is used to perform mouse movement. We have to import org.openqa.selenium.interactions.Actions for Action class. Along with moveToElement() we have to use the perform() method ... Read More

Find Element Containing Specific Text in Selenium WebDriver

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:18:35

2K+ Views

We can find an element with a specific text visible on the screen in Selenium. This is achieved with the xpath locator. The xpath locator contains some in-built functions that help to create customized xpath.Let us consider a portion of the web page as given below −text() − It is a built in function to identify an element based on the text displayed on the screen. For example, if we want to identify Library from the above webpage, the customized xpath with text() should be −Syntax//*[text()='Library']contains() − It is a built in function to identify an element based on the ... Read More

Take Screenshot with Selenium WebDriver

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:09:49

3K+ Views

Whenever we encounter a failure during testing, it is a common nature to capture the screenshots wherever there is a deviation from the expected result. Thus it is considered a mandatory step to attach a screenshot for creating a bug.While automating a bunch of test cases of a considerable number, capturing screenshot is critical to infer why a test case has failed for both the development and testing team. As they debug the failures, going through the screenshot and conclude if the failure is due to script issue or defect in the application.Let us discuss which part of the page ... Read More

Handle Windows-Based Pop-Ups with Selenium

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:04:55

4K+ Views

Selenium can handle Windows based pop up. There may be scenarios where a web page opens more than one window after performing some actions on it. The child windows that get opened may be a pop up containing some information or advertisement.Selenium uses the getWindowHandles () and getWindowHandle () methods to work with child windows. The getWindowHandles () method contains all the window handle ids of the opened windows. The window id handles are held in the form of Set data structure [containing data type as String].The getWindowHandle () method is used to store the window handle id of the ... Read More

Difference Between Selenium IDE, RC, and WebDriver

Debomita Bhattacharjee
Updated on 28-Aug-2020 06:01:09

5K+ Views

The differences between selenium IDE, RC & Webdriver are listed below :FunctionalitiesSelenium IDESelenium RCSelenium WebdriverRecord and playbackIt has the record and playback feature.It does not have a record and playback.It does not have a record and playback.ServerIt requires no server to start execution of test cases.It requires the server to start execution of test cases.It requires no server to start execution of test cases.BrowserIt can be used for testing only in Firefox.It can be used for testing in the majority of browsers.It can be used for testing in the majority of browsers including in headless mode.Object OrientedIt is based on ... Read More

Construct Maximum Sum Linked List from Two Sorted Lists in Python

Arnab Chakraborty
Updated on 27-Aug-2020 14:25:51

265 Views

Suppose we have two sorted linked lists, we have to make a linked list that consists of largest sum path from start node to end node. The final list may consist of nodes from both input lists.When we are creating the result list, we may switch to the other input list only for the point of intersection (two node with the same value in the lists). We have to solve it using constant amount of extra space.So, if the input is like [6, 8, 35, 95, 115, 125], [5, 8, 17, 37, 95, 105, 125, 135], then the output will ... Read More

Advertisements