Documents

Selenium Mands

Categories
Published
of 7
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Description
testing
Transcript
  These are generic ways to do certain common task i.e.Id: WebElement element = driver.findElement(By.id( ));Name: WebElement element = driver.findElement(By.name( ));Tag Name: WebElement frame = driver.findElement(By.tagName( iframe ));Xpat<fieldset><input type= hidden value= partner name= source ><label class= block clearfix ><span class= block input-icon input-icon-right >CSS: WebElement element = driver.findElement(By.CSS.name( ));LinkText: WebElement element = driver.findElement(By.LinkText.( ));I hope these commands will let you work with Selenium WebDriver like a star. Please leave us a comment and share your own experiences, commands with us.· Testing · 0 Comments Popup Windows and FramesPopup window handling is one of the must handle things in Automation and Webdriver does is really well. Using the window handle command.String winHandleBefore = driver.getWindowHandle(); for(String winHandle : driver.getWindowHandles()){ driver.switchTo().window(winHandle); }1234String winHandleBefore = driver.getWindowHandle();for(String winHandle : driver.getWindowHandles()){driver.switchTo().window(winHandle);}Once action is performed, switch back to parent window.driver.switchTo().window(driver.getWindowHandle());1driver.switchTo().window(driver.getWindowHandle());List BoxSelect an item in Listbox using Selenium Webdriver is quite easy, there two way  s to do it.WebElement select = driver.findElement(By.id( selection )); List&lt;WebElement&gt; options = select.findElements(By.tagName( option )); for (WebElement option : options) { if( Germany .equals(option.getText())) option.click(); }  123456WebElement select = driver.findElement(By.id( selection ));List&lt;WebElement&gt; options = select.findElements(By.tagName( option ));for (WebElement option : options) {if( Germany .equals(option.getText()))option.click();}OrWebElement roleDropdown = driver.findElement(By.id( ); roleDropdown.click();12WebElement roleDropdown = driver.findElement(By.id( );roleDropdown.click();ThenWebElement roleOptionOne = driver.findElement(By.id(FIRST_OPTION)); roleOptionOne.click();12WebElement roleOptionOne = driver.findElement(By.id(FIRST_OPTION));roleOptionOne.click();Right ClickWebElement webelement = driver.findElement(By.xpath( *Xpath Locator* )); Actions actions = new Actions(driver); Action action = actions.contextClick(webelement).build(); action.perform(); <h2>Double Click</h2> Actions action = new Actions(driver); action.doubleClick(myElemment); action.perform();123456789WebElement webelement = driver.findElement(By.xpath( *Xpath Locator* )); Actions actions = new Actions(driver);Action action = actions.contextClick(webelement).build();action.perform();  <h2>Double Click</h2>Actions action = new Actions(driver);action.doubleClick(myElemment);action.perform();Excel ReaderRead or write data from excel using the jxl or POI, I will prefer POI. Create a property reader file then read the dataWorkbook workbook = WorkbookFactory.create(new FileInputStream(file)); Sheet sheet = workbook.getSheetAt(0);12Workbook workbook = WorkbookFactory.create(new FileInputStream(file));Sheet sheet = workbook.getSheetAt(0);Database ConnectionTo connect to Database using WebDriver with Java, we use DBC(  Java Database Connectivity) API.DriverManager.getConnection(URL, username , password )1DriverManager.getConnection(URL, username , password )Time Outs   WaitImplicit Waits:driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);1driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);OrThread.sleep(1000);1Thread.sleep(1000);Explicit WaitsWebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id( someid ))); <h2>Alert Box</h2> driver.findElement(By.id( updateButton )).click(); Alert alert = driver.switchTo().alert();12345WebDriverWait wait = new WebDriverWait(driver, 10);WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id( someid )));<h2>Alert Box</h2>driver.findElement(By.id( updateButton )).click();  Alert alert = driver.switchTo().alert();alert.accept(); or alert.dismiss();Navigationdriver.navigate().to(www.google.com); driver.get( http://www.google.com ); driver.navigate().forward(); driver.navigate().back(); driver.navigate().refresh(); driver.manage().deleteAllCookies(); driver.close();1234567driver.navigate().to(www.google.com);driver.get( http://www.google.com );driver.navigate().forward();driver.navigate().back();driver.navigate().refresh();driver.manage().deleteAllCookies();driver.close();Table ColumnsWebElement Table = driver.findElement(By.id( ))); List&lt;WebElement&gt; Row = Table.findElements(By.tagName( tr ));12WebElement Table = driver.findElement(By.id( )));List&lt;WebElement&gt; Row = Table.findElements(By.tagName( tr ));Drag And DropWebElement element = driver.findElement(By.name( source )); WebElement target = driver.findElement(By.name( target )); (new Actions(driver)).dragAndDrop(element, target).perform();1234WebElement element = driver.findElement(By.name( source ));WebElement target = driver.findElement(By.name( target )); (new Actions(driver)).dragAndDrop(element, target).perform();Mouse OverActions actions = new Actions(driver); WebElement mouseover = driver.findElement(By.id( )); actions.moveToElement(mouseover); actions.click().perform();1234Actions actions = new Actions(driver);WebElement mouseover = driver.findElement(By.id( ));

TedDocument en US

Jul 23, 2017

10-23

Jul 23, 2017
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks