本文介紹了量角器在 div 中按標簽查找元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在一個 HTML 頁面中有一個 div,它的名稱總是已知的,在這個 div 里面有一個 href,它的細節(jié)是未知的.它可能是父母的直系子女,也可能是進一步的孫子女.看起來像這樣:
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 parent or it could be a further grandchild. Looks something like this:
<div class="divName">
...
<a href="some url">some text</a>
...
</div>
我知道這個 div 中只有一個鏈接,所以我想找到一個鏈接并單擊它.
I know that there will only be one link within this div, so I want to find the one link and click it.
我嘗試了以下方法,但似乎不起作用:
I've tried the following but it doesn't seem to be working:
element(by.classname('divName')).find('a').click();
有什么想法嗎?
推薦答案
element(by.css('.divName a')).click();
或者更短的符號:
$('.divName a').click();
這篇關于量角器在 div 中按標簽查找元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!