元素:
<input type="text" class="form-control" placeholder="What's this article about?" >
Run Code Online (Sandbox Code Playgroud)
我是如何识别的:
cy.get("input[placeholder=`What's this article about?`]").type("<3");
Run Code Online (Sandbox Code Playgroud)
错误:
语法错误,无法识别的表达式:
input[placeholder=What's this article about?]
我试图从元素调用文本/aria-标签,但我得到一个对象:
元素:
<p class="styles_startingColumn__8EIiq" data-cy="listValues_popup_txt" aria-label="1+" data-mui-internal-clone-element="true">1+</p>
Run Code Online (Sandbox Code Playgroud)
代码 :
getFirstValueInList() {
return cy.get("[data-cy='listValues_popup_txt']").should('be.visible').eq(0).invoke('attr','aria-label');
}
getFirstValueInList() {
return cy.get("[data-cy='listValues_popup_txt']").should('be.visible').eq(0).invoke('text');
}
Run Code Online (Sandbox Code Playgroud)