Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selenium Web Driver Articles
Page 4 of 13
How do you check scroll position using selenium?
We can check scroll position using Selenium. To check the position we shall use the Javascript executor. We have to verify the value of the window.pageYOffset in the browser.While the URL is launched, the scroll is at the top the value of window.pageYOffset is 0. As we scroll to an element, the value of the window.pageYOffset shall be greater than 0.SyntaxJavascriptExecutor j = (JavascriptExecutor) driver; Long v = (Long) j.executeScript("return window.pageYOffset;");Exampleimport 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 org.openqa.selenium.JavascriptExecutor; public class ScrollPosition{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); ...
Read MoreHow do you get selenium to recognize that a page loaded?
We can get Selenium to recognize that a page is loaded. We can set the implicit wait for this purpose. It shall make the driver to wait for a specific amount of time for an element to be available after page loaded.Syntaxdriver.manage().timeouts().implicitlyWait();After the page is loaded, we can also invoke Javascript method document.readyState and wait till complete is returned.SyntaxJavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("return document.readyState").toString().equals("complete");After this, verify if the URL matches the one we are looking for.ExampleCode Implementation with implicit wait.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; public class Pageload{ public static void main(String[] args) { ...
Read MoreHow to verify specific text exists within an attribute in Selenium IDE?
We can verify specific text exists with an attribute in Selenium IDE. This can be done using the assert and verify commands −assert element present − Verifies if the element exists on the page. If assertion fails, the test terminates. It has the element locator as an argument.For example −assert element not present − Verifies if the element does not exist on the page. If assertion fails, the test terminates. It has the element locator as an argument.verify element present − Verifies if the element exists on the page. It has the element locator as an argument.verify element not present ...
Read MoreHow to select value from a drop down using Selenium IDE?
We can select value from a dropdown using Selenium IDE. The select command is used for this purpose. First of all, Selenium IDE add-on should be installed in Firefox.Launch Firefox and select the Tools menu. Then choose Selenium IDE.Selenium IDE window shall open. Choose the first row inside the test script edit box.Enter select in Command field. To identify the dropdown with the id locator, enter the Target field. The value/index of the option to be selected is to be entered inside the Value field.Once done, click on the Run option.
Read MoreThe Architecture of Selenium WebDriver.
The architecture of Selenium webdriver are illustrated below −Image source:https://www.tutorialspoint.com/what−is−web−driver−in−seleniumSelenium webdriver has the following units −Selenium Binding Languages − Selenium can work on various libraries like Java, Python, Ruby, and so on. It has the language bindings for more than one language.JSON Wire Protocol − JSON is Javascript Object Notion. It is used for transferring data from the server to the client on the web page. It is based on the Rest API that transmits information among HTTP servers.Browser Driver − All the browsers have a specific browser driver. They interact with the browsers (hiding the logic of browser functionality). ...
Read MoreHow do I download Selenium RC?
We can download Selenium RC by downloading the Java jar file − selenium−server−standalone.jar. We have to download and extract the zip file to do the actual installation.Using the Java Client Driver, the installation can be done by the below steps −To run the Selenium RC server, Java should be installed properly and the path of the environment variable correctly set. To check if Java is installed run the command −java −versionNavigate to the link: https://www.selenium.dev/downloads/ and download the Selenium java client driver zip file.Then the selenium−java jar file is to be extracted.Open an IDE say, Eclipse.Create a Java project.Associate the ...
Read MoreHow to run a test method without reporting as passed or failed in pytest?
We can run a test method without reporting as passed or failed in pytest. This test method is generally used as a prerequisite. Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest – version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in wide range testing API, UI, database and so on. The test file of pytest has a naming convention that it starts ...
Read MoreHow to create a worksheet and write some values in it in Selenium with python?
We can create a worksheet and then write some values in it. Excel is a spreadsheet which is saved with the .xlsx extension. An excel workbook has multiple sheets and each sheet consists of rows and columns.Out of all the worksheets, while we are accessing a particular sheet that is called as an active sheet. Each cell inside a sheet has a unique address which is a combination of row and column numbers.The column number starts from alphabetic character A and row number starts from the number 1. A cell can contain numerous types of values and they are the ...
Read MoreHow to get all the values of a particular column based on a condition in a worksheet in Selenium with python?
We can get all the values of a particular column based on a condition in a worksheet in Selenium. Excel is a spreadsheet which is saved with the .xlsx extension. An excel workbook has multiple sheets and each sheet consists of rows and columns.Out of all the worksheets, while we are accessing a particular sheet that is called as an active sheet. Each cell inside a sheet has a unique address which is a combination of row and column numbers.The column number starts from alphabetic character A and row number starts from the number 1. A cell can contain numerous ...
Read MoreHow to get all the values of a particular row based on a condition in a worksheet in Selenium with python?
We can get all the values of a particular row based on a condition in a worksheet in Selenium. Excel is a spreadsheet which is saved with the .xlsx extension. An excel workbook has multiple sheets and each sheet consists of rows and columns.Out of all the worksheets, while we are accessing a particular sheet that is called as an active sheet. Each cell inside a sheet has a unique address which is a combination of row and column numbers.The column number starts from alphabetic character A and row number starts from the number 1. A cell can contain numerous ...
Read More