NOte that Handling SVG elements is not taught by Pavan Kumar sir, so Ask AMU
Also, Handling google dropdown is also pending, he gave code in i think next video of dropdowns, so see it and do it. Also make its notes, as it is important.
Handling Broken Links
:1_one_circle_orange: using Selenium
WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
try { driver.get("https://testautomationpractice.blogspot.com/");
String errorLinkXpath = "//a[normalize-space()='Errorcode 400']"; WebElement errorLinkElement = wait .until(ExpectedConditions .presenceOfElementLocated(By.xpath(errorLinkXpath)));
String errorLinkUrl = errorLinkElement.getDomAttribute("href");
checkBrokenLink(errorLinkUrl);
} catch (Exception e) { System.out.println("An error occurred: " + e.getMessage()); } }
public static void checkBrokenLink(String linkURL) {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
:2_two_circle_orange: Using Rest Assured
WebDriver driver = new ChromeDriver(); driver.manage().window().maximize();
driver.get("https://testautomationpractice.blogspot.com/");
String linkUrl = driver.findElement(By.xpath("//a[normalize-space()='Errorcode 400']")).getDomAttribute("href");
int statusCode = RestAssured.get(linkUrl).statusCode(); System.out.println(linkUrl + " → Status Code: " + statusCode);
if (statusCode >= 400) { System.out.println(linkUrl + " is a Broken Link (Response Code: " + statusCode + ")"); } else { System.out.println(linkUrl + " is Not a Broken Link (Response Code: " + statusCode + ")"); }
SVG Elements
Shadow DOM
:1_one_circle_orange: If composed tree is flatten then follow straight structure i.e. flattened structure
// 1. Locate First-Level Shadow Host var mainShadowHost = driver.findElement(By.cssSelector("book-app[apptitle='BOOKS']")); var mainShadowRoot = mainShadowHost.getShadowRoot(); System.out.println("Level 1 Shadow DOM completed");
// 2. Locate Second-Level Shadow Host var secondShadowHost = mainShadowRoot.findElement(By.cssSelector("app-header[effects='waterfall']")); var secondShadowRoot = secondShadowHost.getShadowRoot(); System.out.println("Level 2 Shadow DOM completed");
// 3. Locate Third-Level Shadow Host var thirdShadowHost = mainShadowRoot.findElement(By.cssSelector("app-toolbar.toolbar-bottom")); var thirdShadowRoot = thirdShadowHost.getShadowRoot(); System.out.println("Level 3 Shadow DOM completed");
:2_two_circle_orange: If composed tree is not flatten then follow nested structure
// 1. Locate First-Level Shadow Host var mainShadowHost = driver.findElement(By.cssSelector("book-app[apptitle='BOOKS']")); var mainShadowRoot = mainShadowHost.getShadowRoot(); System.out.println("Level 1 Shadow DOM completed");
// 2. Locate Second-Level Shadow Host var secondShadowHost = mainShadowRoot.findElement(By.cssSelector("app-header[effects='waterfall']")); var secondShadowRoot = secondShadowHost.getShadowRoot(); System.out.println("Level 2 Shadow DOM completed");
// 3. Locate Third-Level Shadow Host var thirdShadowHost = secondShadowRoot.findElement(By.cssSelector("app-toolbar.toolbar-bottom")); var thirdShadowRoot = thirdShadowHost.getShadowRoot(); System.out.println("Level 3 Shadow DOM completed");