Issue with CSS locator select-react

后端 未结 2 1051
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 10:39

I have an issue with a CSS locator. I have a unique label for the parent, and from there I can get the child that I need.

@FindBy(css = \"[data-qa=\"select-S         


        
2条回答
  •  青春惊慌失措
    2021-01-20 11:35

    You don't have to try to concatenate CSS selectors.

    It would be easier if you could define a parent as a WebElement:

    WebElement seller = driver.findElement(By.cssSelector("[data-qa=select-Seller]"));
    

    And then find elements inside it:

    WebElement sellerDropdown = seller.findElement(By.cssSelector(".select__value-container"));
    
    WebElement closeButton = seller.findElement(By.cssSelector("[data-qa=icon-x]"));
    

    Note how we are using seller.findElement instead of driver.findElement for child elements.


    I am not 100% sure how to describe this in FindBy terms, take a look if this helps:

    • Selenium/PageFactory: Find child elements using parent element's @FindBy?

提交回复
热议问题