![]() ![]() String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue() // read data Ques 20) Write the code for Reading and Writing to Excel through Selenium ? FileInputStream fis = new FileInputStream(“path of excel file”) Just write it once after opening the browser. This code will attach with each and every line of the script automatically. Here it will wait for 10sec if while execution driver did not find the element in the page immediately. Syntax- driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) Ques 19) How do you achieve synchronization in WebDriver ? It return only one WebElement type.įindElements()- it used to find more than one web element. Ques 18) What is the difference between findElement and findElements?Īns- Both methods are abstract method of WebDriver interface and used to find the WebElement in a web page.įindElement() - it used to find the one web element. it is used to identify the immediate child. Ques 17) What is the difference between ‘/’ and ‘//’ ?Īns- //- it is used to search in the entire structure. Ques 16) How do you get the current page URL ? driver.getCurrentUrl() Ques 15) How do you simulate browser back and forward ? driver.navigate().back() If the menu has not been created by using the select tag then we can simply find the xpath of that element and click on that to select. These are the methods of the Select class. Ques 14) How do you click on a menu item in a drop down menu?Īns- If that menu has been created by using select tag then we can use the methods selectByValue() or selectByIndex() or selectByVisibleText(). driver.findElement(By.xpath(“input field”)).sendKeys(“path of the file which u want to upload”) Ques 12) Give the example for method overload in WebDriver.Īns- frame( string), frame( int), frame( WebElement).Īns- To upload a file we can use sendKeys() method. ![]() WebElement source = driver.findElement(By.xpath(“ -”)) //source ele which you want to drag WebElement target = driver.findElement(By.xpath(“ -”)) //target where you want to dropĪct.dragAndDrop(source,target).perform() Ques 11) How do perform drag and drop using WebDriver?Īns- Use Action class Actions act = new Actions(driver) Ques 10) How to perform right click using WebDriver?Īns- Use Actions class Actions act = new Actions(driver) // where driver is WebDriver type To open Chrome browser → tProperty(“”,”path of the chromeDriver.exe file ”) WebDriver driver = new ChromeDriver() WebDriver driver = new InternetExplorerDriver() tProperty(“webdriver.ie.driver”,”path of the iedriver.exe file ”) Ques 9) How do you launch IE/chrome browser?Īns- Before launching IE or Chrome browser we need to set the System property. Then move the control back to main web page-ĭriver.switchTo().window(mainPage) → to switch back to main page. Syntax- String mainPage = driver.getWindowHandle() Īlert alt = driver.switchTo().alert() // to move control to alert popupĪlt.dismiss() // to click on cancel. If the return value of this method is true then it is checked else it is not.Īns- To handle alert pop-ups, we need to 1st switch control to alert pop-ups then click on ok or cancle then move control back to main page. Syntax – driver.findElement(By.xpath( "xpath of the checkbox/radio button")).isSelected() Ques 7) How do you verify if the checkbox/radio is checked or not ? Ques 6) What is the alternate way to click on login button?Īns- use submit() method but it can be used only when attribute type=submit. If the test case fail then it will not stop the execution of that test case. ![]() Verify- it is also used to verify the result. If the test case fail then it will stop the execution of the test case there itself and move the control to other test case. Ques 5) What is the difference between Assert and Verify?Īns- Assert- it is used to verify the result. Ques 4) What are different types of locators ?Īns- There are 8 types of locators and all are the static methods of the By class.īy.id(), By.name(), By.tagName(), By.className(), By.linkText(), By.partialLinkText(), By.xpath, By.cssSelector(). It is very useful to identify the dynamic web elements. String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue() Īns- it is used to find the WebElement in web page. Workbook wb = WorkbookFactory.create(fis) Ques 1) What are the annotations used in TestNG ?Īns: 2) How do you read data from excel ? FileInputStream fis = new FileInputStream(“path of excel file”) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |