How to handle dynamic WebTable In Selenium There are two ways of handling WebTable: Method – 1: • Iterate row and column and get the cell value. • Using for loop • Get total rows and iterate table • Put if(string matches) then select the respective checkbox • Lengthy method Method – 2: • Using custom XPath • Using parent and preceding-sibling tags • No need to write for loop • No full iteration of table • Single line statement • More dynamic • Efficient and fast package SeleniumSessions; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class DynamicWebTableHandle { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/chromedriver"); WebDriver driver = new ChromeDriver(); // launch chrome driver.manage().window().maximize(); // ...
Posts
Showing posts from November, 2019
Highlight , Flash, pagedown, pageview ,generate alert,draw border - Java Script
- Get link
- X
- Other Apps
/* 1. Highlight an Element 2. DrawBorder around an Element 3. Generate custom Alert during Test Execution 4. Click on an Element by using JaveScript 5. Refresh browser by using JavaScript 6. Get Title by using JavaScript 7. Get InnerText of page by using JavaScript 8. Scroll Into View and Scroll Page Down * */ package SeleniumSessions; import java.io.File; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class JavaScriptExecutorConcept { public static void main(String[] args) throws IOException { System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/chromedriver"); ...