How does @CacheLookup work in WebDriver?

后端 未结 3 1885
情歌与酒
情歌与酒 2021-01-12 21:05

I\'m not sure that I understand the caching principle :

@CacheLookup
@FindBy(how = How.ID, using = namespace + signifLvl)
private WebElement sigLvl;
<         


        
3条回答
  •  不思量自难忘°
    2021-01-12 21:39

    Imho the question should rather be : What is the element pointer/id is about ?

    As WebElement doesn't have a state, only methods that call browser. @CacheLookup is only a shortcut for public WebElement el = driver.findElement(By); when initializing WebDriver's PageObject, for instance.

    After you have the instance, you are executing its methods, that call browser.

    The WebElement ID corresponds to a JS element instance. if you go like this on client JS :

    var node1 = document.createElement('a');
    

    and then append it somewhere, remove it from there, append it some place else, etc. and it is still the same node1 instance, the WebElement instance still points to the node1 element, because it is the same JS node instance.

提交回复
热议问题