Random banking type authentication using python and selenium -


i have task of trying enter authentication details memorable word field online banking have 8 digit number , prompted random selection of these.

the number displayed next input box 'enter 5th character'.

input box field:

<input style="border:none;" size="1" maxlength="1" type="password" name="e0" id="eid1" class="mem" value="" tabindex="1">  <input style="border:none;" size="1" maxlength="1" type="password" name="e1" id="eid2" class="mem" value="" tabindex="1"> 

all information held within tr each box below:

<tr>     <td class="white"><input type="hidden" name="0" value="5">enter  8th character </td>     <td class="mem"><input style="border:none;" size="1" maxlength="1" type="password" name="e0" id="eid1" class="memcd" value="" tabindex="1"></td> </tr> 

has come across selenium before?

edited

the form looks

<form method="post" action="nextstage.php" autocomplete="off">     <input type="hidden" name="return" id="returnid" value="" />     <table align="center" cellspacing="1" cellpadding="4">         <tbody><tr>         <td><input type="hidden" name="0" value="0" />enter  1st character </td>         <td colspan="2"><input size="1" maxlength="1" type="password" name="e0" id="eid1" class="enterdetails" value="" tabindex="1" /></td>         </tr><tr>         <td><input type="hidden" name="1" value="2" />enter  3rd character </td>         <td colspan="2"><input size="1" maxlength="1" type="password" name="e1" id="eid2" class="enterdetails" value="" tabindex="2" /></td>         </tr><tr>         <td><input type="hidden" name="2" value="4" />enter  5th character </td>         <td colspan="2"><input size="1" maxlength="1" type="password" name="e2" id="eid3" class="enterdetails" value="" tabindex="3" /></td> 

edit show new code

pattern = re.compile(r"enter (\d+)\w+ character of memorable word") number_string = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(1) > td:nth-child(1)").text number = int(pattern.search(number_string).group(1))  target_input = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(1) > td:nth-child(2) > input[type=password]") target_input.send_keys(secret_string[number])  number_string = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(2) > td:nth-child(1)").text number = int(pattern.search(number_string).group(1))  target_input = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[type=password]") target_input.send_keys(secret_string[number])   number_string = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(3) > td:nth-child(1)").text number = int(pattern.search(number_string).group(1)) target_input = driver.find_element_by_css_selector("#homepane > form > table > tbody > tr:nth-child(3) > td:nth-child(2) > input[type=password]") target_input.send_keys(secret_string[number]) 

locate input enter nth character text using, example, css selector, extract n number text, character secret string index , send password input:

import re  secret_string = "secret string"  pattern = re.compile(r"enter (\d+)\w+ character")  number_string = driver.find_element_by_css_selector("tr > td.white > input").text number = int(pattern.search(number_string).group(1))  target_input = driver.find_element_by_css_selector("tr > td.mem > input[type=password]")  target_input.send_keys(secret_string[number]) 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -