I need to find the text of an element \"score\" on the basis of other element \"SF Lead ID\" on the same row.
\"SF Lead ID\" can be dynamic. for example am using hard c
To extract the score with respect to SF Lead ID you have to induce WebDriverWait for the visibilityOfElementLocated()
and you can use either of the following Locator Strategies:
Using cssSelector
and getText()
:
String sf_id = "00Q1l000003clVhEAI";
System.out.println(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("tr[data-sf-lead-id='" + sf_id + "'] td#lead-score"))).getText());
Using xpath
and getAttribute()
:
String sf_id = "00Q1l000003clVhEAI";
System.out.println(new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//tr[@data-sf-lead-id='" + sf_id + "']//td[@id='lead-score']"))).getAttribute("innerHTML"));