Found 466 Questions for Selenium

How to get rid of Firefox logging in Selenium?

Debomita Bhattacharjee
Updated on 08-Feb-2022 10:44:56
After the execution of tests, there are logs generated because of Firefox logging in with geckodriver. This log generation by Firefox can be disabled by certain parameters setting.We can stop these logs from being recorded in the console and capture them in a different file. This is achieved with the help of the System.setProperty method. In the above image, we can see the geckodriver logs generated in the console.SyntaxSystem.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true"); // turning off logs System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, ""); // record logs in another fileExampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; public class LogsDisable{    public static void main(String[] ... Read More

How to determine colors using Selenium?

Debomita Bhattacharjee
Updated on 08-Feb-2022 10:30:22
Selenium has the color conversion support class. We have to add the statement from selenium.webdriver.support.color import Color to convert colors to rgba/hex format.Examplefrom selenium import webdriver from selenium.webdriver.support.color import Color #color conversion to rgba format print(Color.from_string('#00fe37').rgba) #color conversion to hex format print(Color.from_string('rgb(1, 200, 5)').hex) #color conversion to rgba format print(Color.from_string('green').rgba)Output

What are the Actions class in Selenium?

Debomita Bhattacharjee
Updated on 08-Feb-2022 11:03:54
Selenium can perform mouse movements, keypress, hovering on an element, drag and drop actions, and so on with the help of the ActionsChains class. We have to create an instance of the ActionChains class which shall hold all actions in a queue.Then the method - perform is invoked which actually performs the tasks in the order in which they are queued. We have to add the statement from selenium.webdriver import ActionChains to work with the ActionChains class.Syntax#Method 1 - chained pattern e =driver.find_element_by_css_selector(".txt") a = ActionChains(driver) a.move_to_element(e).click().perform() #Method 2 - queued actions one after another ... Read More

How to use CSS selector as a locator in Selenium?

Debomita Bhattacharjee
Updated on 08-Feb-2022 10:59:14
We can locate elements with locator CSS Selector in Selenium webdriver. The general expression to create a CSS expression is tagname[attribute='value']. We can utilize the id and class attributes to create a CSS.With id, the syntax of a CSS expression is tagname#id. For instance, for a CSS expression - input#txt-loc, input is the tagname and the txt-loc is the value of the id attribute.With class name, the syntax of a CSS expression is tagname.class. For instance, for a CSS expression - input.txt-cls, input is the tagname and the txt-cls is the value of the class attribute.If there are n sub-elements(children) ... Read More

How to get the total number of radio buttons on a page using Selenium?

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:58:10
We can get the total number of radio buttons on a page using Selenium webdriver using the find_elements method. While working on any radio buttons, we will always find an attribute type in the html code and its value should be radio.This characteristic is only applicable to radio buttons on that particular page and to no other types of UI elements like edit box, link, and so on.To retrieve all the elements with attribute type = 'radio', we will use find_elements_by_xpath() method. This method returns a list of web elements with the type of xpath specified in the method argument. ... Read More

How to get the total number of checkboxes in a page using Selenium?

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:55:54
We can get the total number of checkboxes in a page using Selenium webdriver using find_elements method. While working on any checkboxes, we will always find an attribute type in the html code and its value should be checkbox.This characteristic is only applicable to checkboxes on that particular page and no other types of UI elements like edit box, link and so on.To retrieve all the elements with attribute type = 'checkbox', we will use find_elements_by_xpath() method. This method returns a list of web elements with the type of xpath specified in the method argument. In case there are no ... Read More

How to click on a link using Selenium webdriver in Python.

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:36:58
We can click on a link using Selenium webdriver in Python. A link is represented by the anchor tag. A link can be identified with the help of the locators like - link text and partial link text.We can use the link text attribute for an element for its identification and utilize the method find_element_by_link_text. With this, the first element with the matching value of the given link text is returned.Syntaxdriver.find_element_by_link_text("value of link text")We can also use the partial link text attribute for an element for its identification and utilize the method find_element_by_partial_link_text. With this, the first element with the ... Read More

How to select an option in a static dropdown in Selenium?

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:03:24
We can select an option in a static dropdown in Selenium webdriver. Selenium can handle static dropdowns with the help of the Select class. A dropdown is identified with select tagname and its options are represented with the tagname option. The statement - from selenium.webdriver.support.select import Select should be added to work with Select class.Methods under the Select class are listed below −select_by_visible_text (arg) – it shall select all the options which displayed text matches with the argument.Syntax−sel = Select (driver.find_element_by_id ("name")) sel.select_by_visible_text ('Visible Text')select_by_value (arg) – it shall select all the options having a value that matches with the ... Read More

Gmail login fail using Selenium webdriver. Showing element not found for password.

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:35:14
We can encounter Gmail login failure while using Selenium webdriver due to the error - element not found for password. This can be fixed by the methods listed below −Adding implicit wait - Implicit wait is applied to instruct the webdriver for polling the DOM(Document Object Model) for a specific amount of time while attempting to identify an element that is currently unavailable.The default value of the implicit wait time is 0. Once a wait time is set, it remains applicable throughout the entire life of the webdriver object. If an implicit wait is not set and an element is ... Read More

How to send a report through email using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 29-Jun-2021 08:42:55
We can send a report through email using Selenium webdriver. The email report can be an important feature in an automation framework. An email should be necessarily sent after the combined execution of a regression suite has completed to get an overall view of the test results.The ways to send a report through email are listed below −Using the Java library - Apache Commons available in the below link: https://commons.apache.org/proper/commons-email/.Using the Java mail JAR. The details of this is available in the below link: https://javaee.github.io/javamail/Steps to configure the Java mail JAR are listed below −Step1 − Navigate to the below ... Read More
1 2 3 4 5 6 7 ... 47 Next
Advertisements