mercredi 27 juin 2018

Selenium Python find element by name doesn't work

I'm testing the web form with several fields using a PyCharm and Selenium web driver.

There are a two similar DIVs on the webpage for a phone and e-mail:

<div class="popup-subscribe-new__content">
                        <div class="field field_type_email js-field-custom-email js-field">
                            <input type="phone" name="phone" placeholder="Phone Number" autocomplete="off" required="required" class="field__input js-field-input js-inputmask-phone" pattern="^[0-9\+\-\( \)]+$" data-trim="true" pattern-flags="i">
                            <div class="field__error">Enter the phone number</div>
                        </div>
                    </div>

and

<div class="popup-subscribe-new__content">
                    <div class="field field_type_email js-field-custom-email js-field">
                        <input type="email" name="email" placeholder="E-mail" autocomplete="off" required="required" class="field__input js-field-input" pattern="^([A-Za-z0-9_\.\+\-])+@([A-Za-z0-9_\.\-])+\.([A-Za-z]{2,4})$" data-trim="true">
                        <div class="field__error">Enter the e-mail</div>
                    </div>
                </div>

in my test I using phone_field = driver.find_element_by_name('phone') for the phone search and phone_field = driver.find_element_by_name('email') for the e-mail search

As the result, the test successfully found the phone field but after trying to find the email field the PyCharp answered with ElementNotVisibleException: Message: element not visible

Where was I wrong? Thank you, Eugene

Aucun commentaire:

Enregistrer un commentaire