Dec-23-2019, 10:17 PM
hello,
i am trying to login to a suppliers webpage by a selenium script
i use python and chromedriver
i run into following error since 2days and doesnt come to a solution
the website login snippet:
-sendkeys
-click the element first
-implement a wait
-copy paste my text into the textbox
-......
does anybody can help me with this issue?
ps:
i do not like to print the website of my supplier online in a forum, i can send you my code and the website login link in a pm message if you are willing to help me
i am trying to login to a suppliers webpage by a selenium script
i use python and chromedriver
i run into following error since 2days and doesnt come to a solution
Error:selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=79.0.3945.88)
the relevant code:username = driver.find_element_by_xpath('''//*[@id="UserName"]''') print(username) password = driver.find_element_by_xpath('''//*[@id="Password"]''') print(password) knop = driver.find_element_by_class_name("btn-login") print(knop) pyperclip.copy('[email protected]') username.click() username.send_keys(Keys.CONTROL, 'v') #password.clear() password.send_keys('XXXXXXX') knop.submit()the problem is that the supplier changes the class names as soon as you are typing 1 letter into the textboxes
the website login snippet:
Error:<div class="form-holder">
<form action="/profile/login?returnurl=https%3a%2f%2fwww.xxxxxxxxxxxx.com%2f" class="form form-login" method="post" novalidate="novalidate"><input name="__RequestVerificationToken" type="hidden" value="K7gZc26iNJ9BUMXOzCD6kxcEcZERpbvX1MvRCrsu9MzsGEZaA8jMJpAcyrOnFN4gyLwf39-eKIDU4bjnF2EVlA-772Q1"> <div class="form-row row-username row-error">
<div class="control">
<div class="label"><label class="lbl" for="UserName">E-mail address*</label></div>
<div class="field">
<div class="tbx">
<input data-val="true" data-val-length="E-mail address cannot be longer than 80 characters." data-val-length-max="80" data-val-regex="E-mail address is invalid." data-val-regex-pattern="^\s*(((?!\.)[a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9\-]+\.)+([a-zA-Z]{2,}))\s*$" data-val-required="E-mail address is required." id="UserName" maxlength="80" name="UserName" type="email" value="" class="input-validation-error" aria-describedby="UserName-error" aria-invalid="true">
</div>
</div>
</div>
<div class="validation"><span class="field-validation-error" data-valmsg-for="UserName" data-valmsg-replace="true"><span id="UserName-error" class="">E-mail address is invalid.</span></span></div>
</div>
<div class="form-row row-password">
<div class="control">
<div class="label"><label class="lbl" for="Password">Password*</label></div>
<div class="field">
<div class="tbx">
<input autocomplete="off" data-val="true" data-val-length="Password cannot be longer than 30 characters." data-val-length-max="30" data-val-required="Password is required." id="Password" maxlength="30" name="Password" type="password" value="">
</div></div>
</div>
<div class="validation"><span class="field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span></div>
</div>
<div class="form-row row-actions">
<span class="forgot-password"><a href="/profile/forgotpassword" tabindex="-1">Forgot password</a></span>
<span class="remember-me"><label>
<span class="chb">
<input type="checkbox" name="RememberMe" id="RememberMe" value="true">
<ins><!--ins right after input[type="checkbox"] to fix iOS bug--></ins>
<input type="hidden" name="RememberMe" value="false">
</span>
</label>
<label for="RememberMe">Remember me</label></span>
<button class="btn btn-medium btn-login" title="" type="submit">
<span class="btn-cnt">Login</span>
</button>
</div>
</form></div>
i tried several things -sendkeys
-click the element first
-implement a wait
-copy paste my text into the textbox
-......
does anybody can help me with this issue?
ps:
i do not like to print the website of my supplier online in a forum, i can send you my code and the website login link in a pm message if you are willing to help me