[英]How do I click a div with a specific text using Selenium Webdriver?
I am using Selenium Webdriver to test a program in JavaScript. 我正在使用Selenium Webdriver在JavaScript中测试程序。
I want to click on an element that I get after I input some data in a search box. 我想在搜索框中输入一些数据后点击我得到的元素。 The problem is that, as I don't create that object, I can not give it an id in and refer to it while I'm testing.
问题在于,由于我没有创建该对象,因此在测试时我不能给它一个id并引用它。
Is there a way to refer to a tag containing a specific text? 有没有办法引用包含特定文本的标签?
it('Should select a song', function(done) {
client
.setValue('#email', 'partygoer@email.com')
.setValue('#query', 'superstition')
.click('#search')
.waitFor('.cover', 5000)
.click('Here I have to click on the element with the specific text')
.click('#submit')
.waitFor('#thank-you')
.getText('#thank-you', function(err, text) {
expect(text).to.include('hello partygoer@email.com, your song id is')
})
.call(done);
});
我找到了一种方法,通过选择我想要点击的链接的文本,使用以下语法:单击此TextHere我可以.click('link = TextHere'),它将选择该元素..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.