Skip to main content

Posts

Showing posts from February, 2019

Selenium Basic Commands.

Selenium Commands, Packages and Exceptions. Here I have selected few most frequently asked commands in the interview. Recommended way of Importing webdriver from selenium package. from selenium import webdriver. Once webdriver is imported then you are able to access the classes like this webdriver.Firefox webdriver.FirefoxProfile webdriver.Chrome webdriver.ChromeOptions webdriver.Ie webdriver.Opera webdriver.PhantomJS webdriver.Remote webdriver.DesiredCapabilities webdriver.ActionChains webdriver.TouchActions webdriver.Proxy To launch the application URL: driver = webdriver.Chrome driver.get('http://youtube.com') To get URL of the currently loaded page: driver.current_url To close the current window: driver.close() Exceptions in Selenium: Base Exception class: Selenium.common.exceptions selenium.common.exceptions.WebDriverException selenium.common.exceptions.InvalidElementStateException selenium.common.exceptions

Selenium Xpath

XPath  XPath is abbreviated as XML Path.  Xpath is used to find the location of any element on the web page using HTML DOM structure. Basic format of XPath is : Xpath = //tagnanme[@attribute='value'] //  : Select current node. Tagname  : Tagname of the particular node. eg : input, img, div etc @   : Select attribute. Value   : Value of the attribute. Different locators are used to find the element on web pages accurately. ID  ClassName Name LinkText XPath CSSPath Types of XPath: Absolute XPath Relative XPath Absolute xpath: It is direct way to find the element right from the root element of the webpage. The disadvantage of the absolute xpath is that if there are any changes made in the path of the element then xpath gets failed. It begins with the single forward slash(/), which means you can select the element from the root node. example : html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/di