Found 519 Articles for Selenium

How can I select date from a datepicker div using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 03-Apr-2021 10:14:00

2K+ Views

We can select data from a datepicker using Selenium webdriver. A datepicker in a calendar can be designed in numerous ways on the web UI. Based on the UI, we have to design our test.A calendar may have a dropdown for selection of day, month or year. It may also contain forward and backward navigation to move up and down in the dates or any other design. The below example shows a calendar having a datepicker. Let us make an attempt to select the date 03/02/2021(2nd March, 2021) date from the below calendar −In the above html code, we can ... Read More

How to use JavaScript in Selenium to click an Element?

Debomita Bhattacharjee
Updated on 03-Apr-2021 10:13:08

11K+ Views

We can use the JavaScript Executor in Selenium to click an element.Selenium can execute JavaScript commands with the help of the method executeScript.Sometimes while clicking a link, we get the IllegalStateException, to avoid this exception, the JavaScript executor is used instead of the method click. The parameters to be passed to the executeScript method to click an element are - arguments[0].click(); and the web element locator.SyntaxWebElement m=driver.findElement(By.linkText("Company")); JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("arguments[0].click();", m);Let us click the link Company on the below page −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 ClickLnkJS{    public ... Read More

How do I use Selenium with Ruby?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:41:54

1K+ Views

We can use Selenium with Ruby. First of all we have to install Ruby in the system. For installation in Windows, we have to take the help of the RubyInstaller package by navigating to the link −https://rubyinstaller.org/Click on Download.The various versions of Ruby Installers links get displayed. Select the latest version and click on it.Click on the Save File button to download the corresponding rubyinstaller.exe file.Once the download is completed, accept the license agreement and proceed to the next steps till installation is completed.To have Selenium webdriver package for Ruby, run the command −gem install selenium−webdriverTo have Rest−Client package for ... Read More

How to Stop the page loading in firefox programmatically in Selenium ?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:41:38

359 Views

We can stop the page loading in Firefox programmatically. This can be done by first setting page load time with the help of the pageLoadTimeout method.The time to wait for the page load is passed as a parameter to that method.Syntaxdriver.manage().timeouts().pageLoadTimeout(10, TimeUnit.MILLISECONDS);The page is forced to stop from loading with the help of the Javascript Executor. Selenium executes JavaScript command (window.stop() to stop page load) with the help of the executeScript method.Syntax((JavascriptExecutor)driver).executeScript("window.stop();");Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class StopPageLdWait{    public static void main(String[] args) {       System.setProperty("webdriver.gecko.driver",       "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe");       ... Read More

What is meant by Selenium RC?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:31:58

2K+ Views

Selenium RC is a key part in Selenium. It is a framework for testing that allows testers and developers to design test scripts in multiple languages to automate frontend UI test cases. It has a client library and a server that starts and quits the browser sessions by defaultServer injects Selenium core (a program in JavaScript) to the browser. The Selenium Core gets the commands from the RC server. Selenium Core executes the commands in JavaScript. Then the JavaScript commands provide instructions to the browser. Finally, the browser runs the instructions given by the Selenium Core and sends a complete ... Read More

Can Google Chrome be supported by Selenium IDE?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:31:11

332 Views

Initially Selenium IDE was used as a Firefox plugin. But the latest Selenium IDE version supports both Chrome and Firefox. For installation in Chrome, navigate to the below link −ttps://chrome.google.com/webstore/detail/seleniumide/mooikfkahbdckldjjndioackbalphokdThen click on Add to Chrome.Click on Add extension.Once installed, we shall get the below message as shown in the image −Also an icon gets created in the menu bar.Click on that icon, and the Selenium IDE gets launched with the below welcome screen.

How to create nested test suites for Selenium IDE?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:26:38

322 Views

We can create nested test suites for Selenium IDE. A group of tests constitutes a test suite. First, to create a test suite we have to follow the below steps as listed below −Step1: Launch Selenium IDE. Then click on Create a new project link.Step2 − Provide the PROJECT NAME. Then click on OK.Step3 − Select Test Suites from the dropdown under the Project name. Then click on + button.Step4 − Add SUITE NAME, then click on ADD.Step5 − The new suite Test_Suite1 gets created. Click on it and select the option Add tests.Repeat the steps 3 and 4, to ... Read More

How do I use Selenium IDE?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:25:55

269 Views

We can use and install Selenium IDE by following a few steps one by one. It is for integrated development of Selenium scripts. It is primarily used as an extension of Firefox.Some facts about Selenium IDE are listed below −Requires no technical knowledge of the testers.Record and playback feature available.Has the option to run either a single test case or all test cases in a suite.Allows usage of breakpoints for debugging.Auto−completion feature for commands in Selenium.Supports multiple locators like xpath, css, id, and so on.Tests can be saved in multiple formats like Python, C#, and so on.Initially used as a ... Read More

Handle Firefox Not Responding While Using Selenium WebDriver With Python?

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:25:36

567 Views

We can handle the situation in which the Firefox is not responding with the help of the Selenium webdriver in Python. This can be achieved with the help of the FirefoxProfile class.We shall create an object of this class and apply the set_preference method on it. Then pass these preferences − dom.max_script_run_time and dom.max_chrome_script_run_time with their values set to 0 as parameters to that method.Finally, this information shall be sent to the webdriver object.Syntaxf = webdriver.FirefoxProfile() f.set_preference("dom.max_chrome_script_run_time", 0) f.set_preference("dom.max_script_run_time", 0)We can get the above parameters of the browser by following the below steps −Open the Firefox browser.Type about:config in browser ... Read More

Save a Web Page with Python Selenium

Debomita Bhattacharjee
Updated on 02-Feb-2021 12:19:00

11K+ Views

We can save a webpage with Selenium webdriver in Python. To save a page we shall first obtain the page source behind the webpage with the help of the page_source method.We shall open a file with a particular encoding with the codecs.open method. The file has to be opened in the write mode represented by w and encoding type as utf−8. Then use the write method to write the content obtained from the page_source method.Syntaxn = os.path.join("C:\Users\ghs6kor\Downloads\Test", "PageSave.html") f = codecs.open(n, "w", "utf−8") h = driver.page_source f.write(h)Let us make an attempt to save the below webpage −Examplefrom selenium import webdriver ... Read More

Advertisements