Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
5いいね 224 views回再生

Introduction to XPath and How to Identify Elements using XPath II Using Standard Syntax, and , or

In this session you will learn what is XPath and Introduction to XPath and how to Identify Elements using XPath Standard Syntax and using and , or

Please check basic identification types as well

Identify elements using ID, name, Class name :
   • How to Identify Elements using ID   name  ...  

Identify elements using linktext and partial linktext
   • How to Identify Elements using LinkText an...  

Identify elements using tag name
   • How to Identify Elements using tagName II ...  

Identify elements using CSS
   • How to Identify Elements using CSS Selecto...  


What is XPath –
XPath is defined as XML Path
XPath is a language to find elements on a web page using XML Path expression
XPath locates any element on web page using HTML DOM Structure

Types of XPath –
Absolute XPath ( direct traversal to the destination from root node to destination )
Relative XPath ( traversing to the destination node from the node which is not root or somewhere in the middle of the DOM Structure )

============================================================
XPath Example program - identify elements using standard syntax , and , or
============================================================
package com.seleniumbasics;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Locators_XPATH
{
public static void main(String args[])
{
System.setProperty("webdriver.chrome.driver", "E:\\Selenium + Java - Youtube\\Selenium\\Libraries\\chromedriver_win32\\chromedriver.exe");
WebDriver driver =new ChromeDriver();
driver.get("http://demowebshop.tricentis.com/regi...");
driver.manage().window().maximize();

System.out.println("XPATH Examples - Registration Page ");

driver.findElement(By.xpath("//input[@id='gender-male']")).click();
driver.findElement(By.xpath("//input[@id='FirstName']")).sendKeys("test1234");
driver.findElement(By.xpath("//input[@id='LastName' and @name='LastName']")).sendKeys("test3456");
driver.findElement(By.xpath("//input[@id='Email' or @name='Email']")).sendKeys("testknowledgeshare@gmail.com");
driver.findElement(By.xpath("/html/body/div[4]/div[1]/div[4]/div[2]/form/div/div[2]/div[3]/div[2]/div[1]/input")).sendKeys("123456");
driver.findElement(By.xpath("//*[@id=\"ConfirmPassword\"]")).sendKeys("123456");
driver.findElement(By.xpath("//input[@class='button-1 register-next-step-button']")).click();
System.out.println("Registration Successfull");
}
}

コメント