Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am using this Selenium command within the Firefox IDE, it's my first time with Selenium so I may be missing something basic.

<tr>
    <td>click</td>
    <td>css=button.k-button.km-button</td>
    <td></td>
</tr>

When I use the 'find' option it finds the button OK. When I single step through the commands (open web page, select button) I can see the web page open but the click does not work. (The click should go to a new page.) The script then fails because the next step is to enter some data on the other page.

I have set the speed to the slowest setting. I created a simple "google for selenium and select page" script and that worked. Now I'm testing my target application and the very first button click doesn't work!

Ideas? (this is a .net web application)

html from the page for a button:

<button
 class="k-button km-button" 
 data-click="app.goToSignup"  
 data-role="button"  
 style="background-color: rgb(240, 240, 240);" 
>
share|improve this question
    
When you said "doesn't work" do you mean nothing happens, or an exception occurs? It could be an issue of an incorrect css identifier, but we don't have the button html to see if that is the case. Can you include the page's html, or the relevant part of it? We could then create css, xpath or alternative identifiers for you that would work. –  Sam Woods Feb 25 '13 at 16:51
    
Can you provide the exact html that the button is using? –  Bruce McLeod Feb 26 '13 at 4:34
    
Can you post your html? –  Iswanto San Feb 27 '13 at 2:01
    
nothing happens except a timeout –  carolineggordon Feb 28 '13 at 9:22
    
I put the html for the button but the whole page is massive ! it is a .net application using kendoui if that helps. Should I post the entire file? –  carolineggordon Feb 28 '13 at 9:38

4 Answers 4

Reason people are asking for full HTML is because your button might be hidden within div or frame element, and that might be reason why you are able to find the button when you're debugging but it fails to locate when you actually run the script from start.

share|improve this answer
    
OK just for you guys, the application is available here: musicmy.azurewebsites.net if you can give me the selectors to use for both the login and signup buttons - you get my bounty! –  carolineggordon Mar 5 '13 at 9:41
    
css=button.k-button[data-click="app.goToSignup"] This would locate SignUp button but it fails, selenium IDE executes it successfully but Page just stays intact Im not really sure why it wont load, perhaps someone else can help you with that. –  lkhan Mar 5 '13 at 19:45

There are a number of reasons that this could be failing. I will list a couple of them and steps to troubleshoot, but ultimately the problem here is that the IDE with no additional user interaction is not really the intended way for Selenium to be used. It's a nice to have to help you learn and create simple "hello world" style automation. To really use Selenium to its potential, you will need to have some understanding of HTML and CSS as well as be able to modify, extend or replace the selectors and generated IDE code.

  • There are multiple elements which match the element selector that you are using.
    • If alternative selectors are working, this is a likely reason. Often pages will have multiple similar elements, many of which may be hidden and/or disabled that match a selector that the IDE generates. Search the source to see if there are multiple elements that match, if so, use some alternative identifier. XPath and CSS selector will work here since you can give a "path" to your element including parent and ancestor which will make it unique. The default that the IDE comes up with may or may not include enough information to make it unique. You may need to construct an XPATH or CSS selector by hand that will work. For xpath, there are lots of examples online and tools to help you construct or test your xpath queries.
  • The element you are attempting to interact with is inside of an iframe. This requires additional code to switch to the correct frame before interacting with the element.
    • Look up how to work with iframes using selenium IDE.
share|improve this answer
    
OK it helps to get your input. I have started working through a book, it seems it is necessary to learn thoroughly how to select elements. –  carolineggordon Mar 5 '13 at 9:39
    
Thanks Caroline, if you find an answer helpful please remember to upvote it as well. If an answer completely answers your question, you can mark it as accepted so that anyone else with the same question in the future will be able to easily find the correct answer. –  Sam Woods Mar 5 '13 at 17:45

In the Selenium IDE window, click the dropdown next to Target field and select different options like id, name, css, xpath and DOM.

Try executing that, single step(OK button) by selecting xpath once, if it doesn't work, try using ID, Name or DOM.

EDIT

Selector for LOGIN button is

TARGET ===>  //div[@id='view-default']/footer/div/div/button
share|improve this answer
    
wow this is annoying! I am getting somewhere with your advice but looks like every button I have to muck around and try different selections. Have to come back to this tomorrow! –  carolineggordon Feb 28 '13 at 10:26
    
let us know, if the application you are working upon(any similiar application) is available online. So that we can analyse the problem and help you. –  HemChe Mar 4 '13 at 9:15
    
yep, it's here musicmy.azurewebsites.net –  carolineggordon Mar 5 '13 at 9:42
1  
I have gone through the website. The selector for LOGIN button would be //div[@id='view-default']/footer/div/div/button For SIGNUP button, i'm yet to find the selector as there is no consistent behavior for the given selectors. –  HemChe Mar 5 '13 at 14:42

Can you try using selenium builder, It would suggest alternatives for a particular action. Not for promo but i just found the same and blogged it. Please check it in link

share|improve this answer
    
I am loathe to try a new tool right now, surely this works in the IDE? I read a few things suggesting XPATH problems but don't know where to start. I'd rather fix it than switch tools –  carolineggordon Feb 25 '13 at 10:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.