
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 517 Articles for Selenium

30K+ Views
We can have two ways of creating an xpath – relative and absolute. The absolute xpath has the complete path beginning from the root to the element which we want to identify.An absolute xpath starts with the / symbol. One drawback with the absolute xpath is that if there is any change in attributes beginning from the root to the element, our absolute xpath will become invalid.The relative xpath starts by referring to the element that we want to identify and not from the root node. A relative xpath starts with the // symbol. It is mainly used for automation ... Read More

25K+ Views
We can verify the color of a webelement in Selenium webdriver using the getCssValue method and then pass color as a parameter to it. This returnsthe color in rgba() format.Next, we have to use the class Color to convert the rgba() format to Hex. Let us obtain the color an element highlighted in the below image. The corresponding color for the element is available under the Styles tab in Chrome browser.The color of the element is also provided in the hex code #797979.SyntaxWebElement t = driver.findElement(By.tagName("h1")); String s = t.getCssValue("color"); String c = Color.fromString(s).asHex();Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import ... Read More

8K+ Views
We can open a browser window in incognito/private mode with Selenium webdriver in Python using the ChromeOptions class. We have to create an object of the ChromeOptions class.Then apply the method add_argument to that object and pass the parameter -- incognito has a parameter. Finally, this information has to be passed to the webdriver object.Syntaxc = webdriver.ChromeOptions() c.add_argument("--incognito")Examplefrom selenium import webdriver #object of ChromeOptions class c = webdriver.ChromeOptions() #incognito parameter passed c.add_argument("--incognito") #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", options=c) driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/tutor_connect/index.php")OutputRead More

3K+ Views
We can capture the text from the alert message in Selenium webdriverwith the help of the Alert interface. By default, the webdriver object has control over the main page, once an alert pop-up gets generated, we have to shift the webdriver focus from the main page to the alert.This is done with the help of the switchTo().alert() method. Once the driver focus is shifted, we can obtain the text of the pop-up with the help of the method switchTo().alert().getText(). Finally we shall use the accept method to accept the alert and dismiss method to dismiss it.Let us take an example ... Read More

19K+ Views
We can input text in the text box without the method sendKeys with thehelp of the JavaScript Executor. Selenium executes JavaScript commands with the help of the executeScript method.The JavaScript command to be run is passed as parameter to the method. To enter text we shall first identify the input box with the JavaScript method document.getElementById. Then we have to apply the value method on it.Let us enter text Selenium in the below input box −SyntaxJavascriptExecutor j = (JavascriptExecutor)driver; j.executeScript ("document.getElementById('gsc-i-id1').value='Selenium'");Exampleimport 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; import org.openqa.selenium.JavascriptExecutor; public class JsEnterText{ public static void main(String[] ... Read More

7K+ Views
We can obtain all options of a dropdown with Selenium webdriver inPython using the method options. It returns a list of the options in the dropdown.Then we have to use the method text, to get the option text.A dropdown is represented by select tag and its available options are represented by the tagname option. To handle dropdown in Selenium, we have to take the help of the Select class.Let us see the html code of a dropdown along with its options – By Subject and By Name.Syntaxl = driver.find_element_by_name("selType") d = Select(l)for opt in d.options -m = opt.textExamplefrom selenium import ... Read More

4K+ Views
We can click on an image with Selenium webdriver in Python using the method click. First of all, we have to identify the image with the help of any of the locators like id, class, name, css, xpath, and so on. An image in the html code is represented by the img tagname.Let us see the html code of an image element.Exampleimport 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 ImageClk{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implicit wait ... Read More

12K+ Views
We can find an element using the attribute name with Selenium webdriver using the locators - name, css, or xpath. To identify the element with css, the expression should be tagname[name='value'] and the method to be used is By.cssSelector.To identify the element with xpath, the expression should be //tagname[@name='value']. Then, we have to use the method By.xpath to locate it. To locate an element with a locator name, we have to use the By.name method.Let us look at the html code of an element with name attribute −SyntaxWebElement e = driver. findElement(By.name("q")); WebElement m = driver. findElement(By.xpath("//input[@name = 'q']")); WebElement ... Read More

19K+ Views
We can find an element using the attribute id with Selenium webdriver using the locators - id, css, or xpath. To identify the element with css, the expression should be tagname[id='value'] and the method to be used is By.cssSelector.To identify the element with xpath, the expression should be //tagname[@id='value']. Then, we have to use the method By.xpath to locate it. To locate an element with locator id, we have to use the By.id method.Let us look at the html code of an element with id attribute −SyntaxWebElement e = driver. findElement(By.id("session_key")); WebElement m = driver. findElement(By.xpath("//input[@id=' session_key']")); WebElement n = ... Read More

5K+ Views
We can get the tooltip text in Selenium webdriver with help of the method - getAttribute. The attribute title should be passed as a parameter to this method.This technique is only applicable if the element has a title attribute.The tooltip text is the one which gets displayed on hovering the mouse over the element. In the below html code, an element having a tooltip has the attribute title and the value set for title is actually the tooltip text.The below image shows the menu Coding Ground showing the tooltip text as - Coding Ground - Free Online IDE and Terminal.SyntaxWebElement ... Read More