Found 719 Articles for Testing Tools

C Sharp with Selenium - How to Switch one tab to another tab in Csharp Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:47:13

5K+ Views

We can switch one tab to another tab with Selenium webdriver in C#.Sometimes on clicking a link or a button, we can have multiple tabs opened in the same browser.By default, the webdriver can access only the parent tab. To access the second tab, we have to switch the driver focus with the help of the SwitchTo().Window() method. The window handle id of the tab where we want to switch to is passed as a parameter..The method CurrentWindowHandle yields the window handle id of the tab which is in focus. The WindowHandles method returns all the window handle ids of ... Read More

C# and Selenium: Wait Until Element is Present

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:45:02

6K+ Views

We can wait until an element is present in Selenium webdriver using the explicit wait. It is mainly used whenever there is a synchronization issue for an element to be available on page.The WebDriverWait and the ExpectedCondition classes are used for an explicit wait implementation. We have to create an object of the WebDriverWait which shall invoke the methods of the ExpectedCondition class.The webdriver waits for a specified amount of time for the expected criteria to be met. After the time has elapsed, an exception gets thrown. To wait for an element to be present, we have to use the ... Read More

How to set Page Load Timeout using C# using Selenium WebDriver?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:39:38

2K+ Views

We can set page load timeout using Selenium webdriver in C# using the PageLoad method. It is used to set time to wait for loading of the page. An exception will be thrown if the page is not loaded within the timeout specified.Syntaxdriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);Here, 10 is the amount of time in seconds.Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; using OpenQA.Selenium; namespace NUnitTestProject2{    public class Tests{       String url = "https://www.tutorialspoint.com/index.htm";       IWebDriver driver;       [SetUp]       public void Setup(){          //creating object of FirefoxDriver     ... Read More

Moving mouse pointer to a specific location or element using C# and Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:38:51

6K+ Views

We can move mouse pointer to a specific location or element in Selenium webdriver(C#) using the Actions class. We have to first create an object of this class.Next to move an element we have to apply the MoveToElement method and pass the element locator as a parameter to this method. Finally, to actually perform this task the method Perform is to be used.After moving to an element, we can click on it with the Click method. To move to a specific location, we have to use the MoveByOffset method and then pass the offset numbers to be shifted along the ... Read More

How to click button Selenium Python?

Debomita Bhattacharjee
Updated on 24-Aug-2023 21:24:12

46K+ Views

We can click a button with Selenium webdriver in Python using the click() method. First, we have to identify the button to be clicked with the help of any locators like id, name, class, xpath, tagname, or css.Then we have to apply the click() method on it. A button in html code is represented by button tagname. The click operation can also be performed with the help of the JavaScript Executor.Selenium can execute JavaScript command with the help of execute_script() method and the JavaScript command - arguments[0].click() and the webelement locator are passed as a parameter to this methodSyntaxl=driver.find_element_by_id("btn"); l.click(); ... Read More

What are the different ways of handling authentication popup window using Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:36:40

515 Views

We can handle authentication pop-up window using Selenium webdriver by incorporating the username and password within the application URL. The format of an URL along with credential should be − https://username:password@URLLet us launch a web page having the authentication pop-up generated at page load −The user Name and Password fields are having value as admin.If we ignore this pop-up on clicking the Cancel button, we shall be navigated to the below page.If proper credentials are entered and then the OK button is clicked, we shall be navigated to the below page.In the above example, to handle the authentication pop-up, using ... Read More

How can I clear text of a textbox using Python Selenium WebDriver?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:34:27

3K+ Views

We can clear text of a textbox with Selenium webdriver in Python using the clear method. First of all, we have to identify the text box with the help of any of the locators like id, css, name, class, xpath, css, or class.Then we have to enter text into it with the help of the send_keys method. Finally, to clear it we have to use the clear method. We can verify if the text has been cleared with the help of the get_attribute method.Syntaxl = driver.find_element_by_id('txt') l.clear()Let us try to clear the text from the below edit box.Examplefrom selenium import ... Read More

How can I get Webdriver Session ID in Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:31:13

7K+ Views

We can get the webdriver session id with Selenium webdriver using the SessionId class. A session id is a distinctive number that is given to the webdriver by the server.This number is utilized by the webdriver to establish communication with the browser. The commands in our Selenium tests are directed to the browser with the help of this session id. The method getSessionId is used to obtain the webdriver session id.SyntaxSessionId s = ((RemoteWebDriver) driver).getSessionId();Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.SessionId; import org.openqa.selenium.remote.RemoteWebDriver; public class BrwSessionId{    public static void main(String[] args) {       //set ... Read More

How to avoid the pop-up window in chrome browser with Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:30:50

2K+ Views

We can avoid the pop-up window in Chrome browser with Selenium webdriver using the ChromeOptions class. We have to create an object of this class and apply the setExperimentalOption method to it. We shall create a Map and insert the below Chrome browser preference to it −profile.default_content_setting_values.notifications, and set its value to 2.The above browser preference shall be passed as a parameter to the method setExperimentalOption and finally added to the webdriver object.SyntaxMap pf = new HashMap(); pf.put("profile.default_content_setting_values.notifications", 2); ChromeOptions p = new ChromeOptions(); p.setExperimentalOption("prefs", pf);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.HashMap; import java.util.Map; import org.openqa.selenium.WebDriver; public class PopupDisable ... Read More

How can I delete an element in Selenium using Python?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:30:25

6K+ Views

We can delete an element in Selenium webdriver using Python with the help of JavaScript Executor. Selenium is not capable of modifying the structure of DOM directly.It has the feature of injecting JavaScript into the webpage and changing the DOM with the help execute_script method. The JavaScript command to be used is passed as a parameter to this method.JavaScript command to delete an element is −var l = document.getElementsByClassName("tp-logo")[0]; l.parentNode.removeChild(l);The above script is to be passed as a parameter to the execute_script method.Let us try to remove the highlighted logo from the below page −Examplefrom selenium import webdriver #set chromodriver.exe ... Read More

Advertisements