Locators in selenium(for locating web element-static method in By class)



2locatorinspect element on web page
<input placeholder="Patient First Name" maxlength="30" class="form-control jqName" size="30" type="text" name="appointment[patient_attributes][firstname]" id="appointment_patient_attributes_firstname">idunique
driver.findElement(By.id("appointment_patient_attributes_firstname"));
class
driver.findElement(By.class("form-control jqName"));
classname
driver.findElement(By.className("appointment[patient_attributes][firstname]"));
cssSelector()
WebElement ref = driver.findElement(By.cssSelector("input[class='form-control jqName']"));
<a href="https://www.credihealth.com/doctors">Doctors Network</a>linkText()
WebElement ref = driver.findElement(By.linkText("Doctors Network"));
partiallinktext()
WebElement ref = driver.findElement(By.partialLinkText("Doctors Net"));
tagName
WebElement ref = driver.findElement(By.tagName("input"));

Comments

Popular posts from this blog

Run Selenium Tests on Chrome Browser

Collection Framework

Emulate Chrome Browser into mobile View by Using Selenium part-1