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 very new to the world of QA and selenium. I have been trying to create a number of tests to run and cannot seem to get the commands to work properly on one specific drop down. When I execute the commands individually I am able to get the command in question to input a value correctly and then move onto the next command. This has been fairly frustrating because an error will appear that states that the id I am specifying does not exist but when I execute the command by itself, it the value populates. Also the element ID does indeed exist in DOM.

The id in question is name=braintree_basic[cc_type].

I'm starting to think that there is a lag time with something loading.

Thanks.

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://kolin.test.chalkfly.com" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>http://chalkfly.com/</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=search</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=search</td>
    <td>red pen</td>
</tr>
<tr>
    <td>click</td>
    <td>css=button.btn-cart.btn</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=Checkout</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>xpath=(//button[@type='button'])[3]</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=login:guest</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=onepage-guest-register-button</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:firstname</td>
    <td>john</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:lastname</td>
    <td>doe</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:email</td>
    <td>joe@cool.com</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:street1</td>
    <td>123 fake street</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:city</td>
    <td>detroit</td>
</tr>
<tr>
    <td>select</td>
    <td>id=billing:region_id</td>
    <td>label=Michigan</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:postcode</td>
    <td>48348</td>
</tr>
<tr>
    <td>type</td>
    <td>id=billing:telephone</td>
    <td>248.123.3456</td>
</tr>
<tr>
    <td>click</td>
    <td>css=#billing-buttons-container &gt; button.button</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>css=#shipping-method-buttons-container &gt; button.button</td>
    <td></td>
</tr>
<tr>
    <td>select</td>
    <td>id=cc_type_braintree_basic</td>
    <td>label=Visa</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>name=form_submit</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=cc_number_braintree_basic</td>
    <td>4111111111111111</td>
</tr>
<tr>
    <td>select</td>
    <td>id=cc_expiration_month_braintree_basic</td>
    <td>label=03 - March</td>
</tr>
<tr>
    <td>select</td>
    <td>id=cc_expiration_year_braintree_basic</td>
    <td>label=2016</td>
</tr>
<tr>
    <td>type</td>
    <td>id=cc_cvn_braintree_basic</td>
    <td>123</td>
</tr>

</tbody></table>
</body>
</html>
share|improve this question
1  
Have you looked into the Wait command - for example other questions like this- sqa.stackexchange.com/questions/6588/… –  Phil Kirkham Mar 10 at 17:22
    
Is this the output from Selenium IDE? –  Dan Snell Apr 4 at 20:35

2 Answers 2

It appears on your site that the credit card form is loaded asynchronously meaning it may not be there if you don't have some kind of wait command. In the IDE you can add a command waitForElement and put your dropdown element identifier (id=cc_type_braintree_basic) so that it will wait for the element to be rendered before it tries to interact with it. Running your test in the ide the issues seem to be with the

<tr>
<td>click</td>
<td>css=#billing-buttons-container &gt; button.button</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#shipping-method-buttons-container &gt; button.button</td>
<td></td>
</tr>

By placing a WaitForElement between these like:

<tr>
<td>click</td>
<td>css=#billing-buttons-container &gt; button.button</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=shipnote-note</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#shipping-method-buttons-container &gt; button.button</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=cc_type_braintree_basic</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>id=cc_type_braintree_basic</td>
<td>label=Visa</td>
</tr>

That seems to work for me. Also there's a quick hint for adding things like that when your recording your test, you can right click on an element you need to wait for then choose "Show All Available Commands". In the second to last group you'll find WaitForElementPresent which will add the step to your test.

share|improve this answer

When I work with Selenium and drop downs, it usually looks like the following:

command: select
target: id=DropDownId value: label=label_id or value=Values_name

share|improve this answer

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.