Selenium Webdriver java 积累 二

1. Selenium webdriver XPATH通过多个属性定位元素
方法:主要是通过and组合多个属性,例如:
wd.findElement(By.xpath("//em[ @testid='123' and @id='button_delete']")).click();

2. selenium webdriver 多个tab选项卡中测试(tab切换)
方法:通过getWindowHandles()方法,获得每个选项卡的WindowHandle,然后通过switchTo().window(WindowHandle)切换到指定的tab。本质上和切换frame一回事。

提供一个方法GotoWebBrowserTab:通过输入tab的顺序去切换到指定的tab。
public static voidGotoWebBrowserTab(WebDriver wd, int iTabID) throws InterruptedException
{
ArrayList tabs= newArrayList();
for (String childTab :wd.getWindowHandles()) 
{
tabs.add(childTab);
}
if(iTabID>tabs.size())
{
Assert.fail( "The expected tab numbershould < actual tab size ");
}
wd.switchTo().window((String) tabs.get(iTabID-1));
GL.wait(1);
}
备注:iTabID 为需要跳转到的tab次序,例如:切换到第2个tab,iTabID为2.
使用方法:
    直接调用方法GotoWebBrowserTab(wd,2)就可以切换到指定的tab。

Book Description Selenium WebDriver is an open source automation tool implemented through a browser-specific driver, which sends commands to a browser and retrieves results. The latest version of Selenium 3 brings with it a lot of new features that change the way you use and setup Selenium WebDriver. This book covers all those features along with the source code, including a demo website that allows you to work with an HMTL5 application and other examples throughout the book. Selenium WebDriver 3 Practical Guide will walk you through the various APIs of Selenium WebDriver, which are used in automation tests, followed by a discussion of the various WebDriver implementations available. You will learn to strategize and handle rich web UI using advanced WebDriver API along with real-time challenges faced in WebDriver and solutions to handle them. You will discover different types and domains of testing such as cross-browser testing, load testing, and mobile testing with Selenium. Finally, you will also be introduced to data-driven testing using TestNG to create your own automation framework. By the end of this book, you will be able to select any web application and automate it the way you want. What you will learn Understand what Selenium 3 is and how is has been improved than its predecessor Use different mobile and desktop browser platforms with Selenium 3 Perform advanced actions, such as drag-and-drop and action builders on web page Learn to use Java 8 API and Selenium 3 together Explore remote WebDriver and discover how to use it Perform cross browser and distributed testing with Selenium Grid Use Actions API for performing various keyboard and mouse actions Who this book is for Selenium WebDriver 3 Practical Guide is for software quality assurance/testing professionals, software project managers, or software developers interested in using Selenium for testing their applications. Prior programming experience in Java is necessary. Table of Contents Introducing WebDriver and WebElements Working with Browser Drivers Using Java 8 features along with Selenium Exploring the Features of WebDriver Exploring Advanced Interactions of WebDriver Understanding WebDriver Events Exploring RemoteWebDriver Setting up Selenium Grid The PageObject Pattern Mobile Testing on iOS and Android using Appium Data Driven Testing with TestNG Assessments
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值