Relative locators in Selenium 4 Java
QuizMediumJava onlyAsked in: Accenture, Infosys, Wipro
Which Java code finds the input that sits to the right of the label label[for='email'] using a Selenium 4 relative locator?
driver.findElement(RelativeLocator.with(By.tagName("input")).toRightOf(By.cssSelector("label[for='email']")))driver.findElement(By.relative("input", "rightOf", "email"))driver.findElement(By.cssSelector("label[for='email']")).toRightOf(By.tagName("input"))new RelativeLocator(driver).rightOf("email")
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.