nateshmbhat / webbot

Web automation library for simple and easy end to end testing and web browser automation that offers super charged features while keeping it simple to use and master
https://pypi.org/project/webbot/
Mozilla Public License 2.0
239 stars 87 forks source link

HTML form - input elements using id tag cannot be reached #21

Open mohijarada2017 opened 5 years ago

mohijarada2017 commented 5 years ago

Hi Natesh,

I would like to thank you for the amazing webbot python API (latest ver: 0.1.4), I started using it for different web automation sites and appreciated.

One technical API issue found: if the web HTML page, has an HTML form and most input types does not have an HTML ID like below example, then your webbot Python API does not work well. Why?

<form method="post" name="form" action="login.cgi" target=""> <input type="text" id="login_username" name="login_username" tabindex="1" class="form_input" maxlength="20" autocapitalize="off" autocomplete="off" placeholder="Username"> <input type="password" name="login_passwd" tabindex="2" class="form_input" maxlength="16" placeholder="Password" autocapitalize="off" autocomplete="off">   | .......  

Then using webbot API here for password does not work at all: web.type('password_value', into='login_passwd') # or web.type('password_value', into='login_passwd', tag='password')

Thanks and appreciated if you can fix this, really important for the Webbot API

Mohee Jarada

nateshmbhat commented 4 years ago

the into parameter is used to specify the field text or placeholder that you see on the website , if it has an id , then specify the id directly using id parameter to the type method like so :

web.type('password_value', id='password_field_id')

if it doesn't have id , u can still give web.type('password_value', into='Password') since it has a placeholder called 'Password'

mohijarada2017 commented 4 years ago

test_python_example_sourcecodes.zip

Thanks Natesh. I already tried out with different HTML forms with name attribute or without, and your API does not catch the placeholder, for the targeted input field I would like to web automate it.

For HTML elements with id attribute, it's working perfectly.

There are a lot of projects with HTML forms without ID or NAME HTML attributes, then how webbot API will capture these?

Attached "test_python_example_sourcecodes.zip", which contains a sample example of Python (webbot_5_example_localhost_html_form_submission.py) HTML webbot auto form submission, using your API. Inside the zip file also: a "test.html", where you can test HTML form with ID or without ID like using HTML input name attributes, as said before with HTML input ID attributes your API works perfectly and webbot web automation will work smoothly, but using HTML name attribute with your API 'into' does not capture the HTML input placeholder at all!!

#web.type(username_str, into = 'firstname')    
#web.type(userpwd_str, into = 'lastname')

then you can un-comment my code line Python two lines actually and you can run it under Python default HTTP web server:

python3.7 -m http.server

you can check it by yourself also.

nateshmbhat commented 4 years ago

Thank u so much. I will definitely work on a fix for this