Showing posts with label All commands of Selenium. Show all posts
Showing posts with label All commands of Selenium. Show all posts

What is the difference between absolute and relative Xpath?


Absolute Xpath : 

1) start selection from the document node
2) Starts with //
3) e.g. “/html/body/p” matches all the paragraph elements

Google Search Box : /html/body/div[1]/div[2]/div[1]/div[1]/div[3]/div/div/div/form/fieldset[2]/div/div/div

Relative Xpath  : 

1) start selection matching anywhere in the document
2) Starts with /
3) e.g. “//p” matches all the paragraph elements starts with p

Google Search Box : //*[@id='gbqfqwb']

How to Zoom In and Zoom Out in Website

In case, you want to zoom in and out in any website using Selenium. You can follow below commands:

To Zoom In:

WebElement Sel= driver.findElement(By.tagName("html"));
sel.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));

To Zoom Out to normal page, use below command:

html.sel(Keys.chord(Keys.CONTROL, "0"));

This can be useful when you need to pin point something while showing your automation framework to any user. 

Selenium Webdriver Commands


This is the key of Selenium Webdriver Commands. These are the most commands which will help you in writing your scripts. 


Selenium WebDriver Commands
Selenium Webdriver Commands