lundi 2 mars 2015

How do I click a div with a specific text using Selenium Webdriver?

I am using Selenium Webdriver to test a program in 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.


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);
});

Aucun commentaire:

Enregistrer un commentaire