Home > Software design >  How to locate the webelement in the picture
How to locate the webelement in the picture

Time:07-22

I need to locate the web element in the picture

enter image description here

Any help would be great

CodePudding user response:

if an element has an id attribute, using By.id locator is the best way to locate such element

WebElement element = driver.findElement(By.id("filter-msg-ports"));

CodePudding user response:

To locate the desired element you can use either of the following Locator Strategies:

  • Using Java and cssSelector:

    WebElement element = driver.findElement(By.cssSelector("span#filter-msg-ports[title='Multiple Ports']"));
    
  • Using Python and xpath:

    element = driver.find_element(By.XPATH, "//span[@title='Multiple Ports' and text()='Multiple Ports']")
    
  • Related