我的页面上有一个按钮,如下所示:
button type="submit" name="username" value="123wq"
class="user-option__action">test1</button>
<span class="user-option__description">TM</span>
我尝试了以下代码:
element(by.buttonText("test1")).click();
browser.actions().mouseMove(btntest1).click();
element(by.css('button[value="1"]')).click();
element(by.buttonText('test1')).click();
element.all(by.id('test1')).get(0).click();
element( by.css( '.select option[value="test1"]' ) ).click();
element(by.css('.test1')).click();
//selenium.click(NEXT_BUTTON_XPATH)
element(by.xpath('//input[@value='123wq'][@title='test1’]')).click();
答案 0 :(得分:0)
之前我理解得很差,你想使用cssContainingText()http://www.protractortest.org/#/api?view=ProtractorBy.prototype.cssContainingText
所以,看起来应该是这样的:
element(by.cssContainingText('button[type=submit]',"test1"))