jeudi 30 avril 2015

cannot insert the username in to the field even though it is getting the id in selenium python

I am new to selenium. I want to test my site. I want to test with more than 100 clients. I have written this code. The strange part is that the password field is filling up but the username field is not filling up. The value is_displayed() is returning true but the data is not inserting into the field. Any help will be highly appreciated.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys 
import time
browser = webdriver.Firefox()
browser.get('http://ift.tt/1DDWbRg' )
print browser.current_url
for i in range(0,10):
    time.sleep(1)

username = browser.find_element_by_id("username" )
password = browser.find_element_by_id("password" )
submit   = browser.find_element_by_id("usernameButton")
a = username.is_displayed()
print a #prints true as it can find the id =username
username.send_keys("please god")
password.send_keys("display" )
submit.click()

Here is the HTML for it

<form id="username_form">
<div id="username_taken" class="alert alert-danger" role="alert">Sorry, that username is taken.</div>
<div class="form-group">
    <label for="uname" class="control-label">Username:</label>
    <br>
    <input type="text" class="form-control" placeholder="Enter your username."
    id="username">
    <br>
    <label for="password" class="control-label">Password:</label>
    <br>
    <input type="password" class="form-control" class="form-control" data-toggle="tooltip"
    data-placement="top" title="Please enter your password to unlock the contacts"
    placeholder="Enter your password (optional)" id="password">
    <br>
    <div class="togglebutton">
        <label>
            <input type="checkbox" id="private"> Allow my friends to find me. </label>
    </div>
</div>
<div class="modal-footer">
    <button id="usernameButton" type="button" class="btn btn-success">Submit</button>
</div>

Aucun commentaire:

Enregistrer un commentaire