Found 519 Articles for Selenium

What is the command used to register gecko driver in Selenium?

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

276 Views

We can register a gecko driver with Selenium webdriver. For the Firefox versions greater than 47, we can execute tests in Firefox with the geckodriver.exe file. To download this executable file, visit the below link − https://github.com/mozilla/geckodriver/releasesNext, we have to choose the link of the zip file which is compatible with our local operating system. As the download of the zip file is done, it has to be extracted and the file – geckodriver.exe should be saved in a location.To register this geckodriver.exe file, we have to set the path of the geckodriver.exe file with the System.setProperty method. Also we ... Read More

How can Selenium select each div separately that have the same class?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:35:37

4K+ Views

We can select each div separately that have the same class with the help of the Selenium webdriver. Often in the html code, we find more than one div element having a class attribute with the same value.Let us see the html code of elements with div tag having the same value set for the class attribute (as highlighted in the image). The value of the class attribute is - colsm-5 col-xs-8 store-details sp-detail paddingR0.To identify each of these div elements separately, we shall use the method findElements and pass the value of the class attribute as a parameter to ... Read More

Is there any way to load an extension in chrome browser using Selenium Webdriver?

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

699 Views

We can load an extension in Chrome browser using Selenium webdriver.While we are using the Chrome browser in our local system, we can add multiple extensions to it.However, while Chrome browser is launched by Selenium webdriver, those extensions which are available to our local browser may not be present. We have to explicitly add them with the help of the .crx file of the extensions.To add an extension for example, Momentum, navigate to the below link − https://chrome.google.com/webstore/category/extensions.Type Momentum in the search box and hit Enter. Select the correct option from the search results.As the next page is navigated, we ... Read More

What are the benefits of using Selenium as an Automation Testing tool?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:29:37

292 Views

The benefits of using Selenium as an automation testing tool are listed below −It is open-source and comes free without licensing cost.It can used be used with more than one programming languages like C#, Java, Python, JavaScript, and so on.It can be used in more than one platforms like Windows, Mac, Linux, and so on.It can be used for testing an application in more than one browser like Chrome, Firefox, IE, Safari, and so on.It has a big community assistance for resolving users' queries.It can support record and playback features with the help of Selenium IDE.It can reduce use of ... Read More

How to select the text of a span on click in Selenium?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:28:57

17K+ Views

We can select the text of a span on click with Selenium webdriver. To identify the element with span tag, we have to first identify it with any of the locators like xpath, css, class name or tagname.After identification of the element, we can perform the click operation on it with the help of the click method. Then obtain its text with the text method. Let us investigate the html code of a webelement with a span tag.Examplefrom selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #identify element and enter text e = driver.find_element_by_class_name("search") e.send_keys("tutorialspoint@gmail.com") ... Read More

Python + Selenium | How to locate elements in span class & not unique ID

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:28:32

4K+ Views

We can locate elements in span class and not unique id with the help of the Selenium webdriver. We can identify an element having a class attribute with the help of the locator xpath, css or class name.To locate elements with these locators we have to use the By.xpath, By.xpath or By.cssSelector method. Then pass the locator value as a parameter to this method.Let us see the html code of a button having a span class and try to identify it.Examplefrom selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/index.htm") l = driver.find_element_by_id("textemail") l.send_keys("abc@gmail.com") #get value ... Read More

How to handle "Plugin blocked" pop up using Selenium Python?

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

2K+ Views

We can handle plugin popup using Selenium webdriver in Python. Whenever a popup comes on page, we cannot inspect elements within the popup and identify them.Also, in order to access other elements on the page, we have to first either accept default has access to the main page. To interact with the popup, we have to explicitly shift the driver focus with the help of the switch_to.alert() method.The popup mainly consists of a message along with Ok and Cancel buttonsto accept and dismiss a popup respectively. To accept a popup, the method switch_to.alert().accept() is used.To dismiss a popup, the method ... Read More

Find div element by multiple class names in Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:28:49

8K+ Views

We can find elements by multiple class names. If there is an element having more than one value separated by spaces set for the class attributes, it is called the compound class names.Let us see the HTML code of such web elements having compound class names −We shall get an exception if we use both the values - toc and chapters with the class name locator for the above scenario. Instead, the rule is to have only one class attribute value with the class name locator.SyntaxWebElement l = driver.findElement(By.className("toc")); //Invalid locator value with className locator WebElement l = driver.findElement(By.className("toc chapters"));Exampleimport ... Read More

How test runner prioritize test classes for execution in Selenium?

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:26:24

575 Views

We can prioritize tests in TestNG during execution. It must be noted that priority can only be set for test methods with @Test annotation. Lower the priority number set for a test method, higher the priority it gets during execution.Only integer value (positive, zero or negative) can be set as priority. A decimal number can also be set as priority, however it is required to be converted to integer value via typecasting.A test method cannot have multiple priority numbers. Also, the priority for a test method cannot be set from the TestNG XML file.Syntaxpublic class TestNG {    @Test (priority ... Read More

TestNG error:- Cannot find class in classpath using Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:24:27

9K+ Views

We may encounter Cannot find class in classpath exception while executing tests in Selenium with TestNG framework. This can be caused because of the following reasons −In the TestNG XML, the class tag having the name attribute should not have the .java extension.In the TestNG XML, the class file is incorrect and hence unable to determine the classpath of the class.Errors within the project are present, and may require a clean project.In the TestNG XML, the class file name is incorrectThe below image shows an example of this error −Exampleimport org.testng.annotations.Test; public class TestNGP {    @Test    public void ... Read More

Advertisements