Protractor find an element by tag inside a div

前端 未结 4 471
南笙
南笙 2021-02-08 02:10

I\'ve got a div in an HTML Page of which the name is always known and inside this div there is an href, the details of which are not known. It could be the direct child of the

相关标签:
4条回答
  • 2021-02-08 02:19
    element(by.css('.divName a')).click();
    

    Or the shorter notation:

    $('.divName a').click();
    
    0 讨论(0)
  • 2021-02-08 02:21

    figured out a solution:

    ptor.findElement(protractor.By.className('clsName'))
        .findElements(protractor.By.tagName('a'))
        .then(function(links){
            links[0].click();
            //place expects here, otherwise it will run async and your expects will be hit 
            //before the lookup
    });
    

    This seems to work pretty well for my purposes

    0 讨论(0)
  • 2021-02-08 02:34

    it seems sytax error in your code

    use this

    element(by.className('divName')).find('a').click();
    
    0 讨论(0)
  • 2021-02-08 02:41

    One line answer

    try with element('.divName a').click();

    0 讨论(0)
提交回复
热议问题