The objective is to sent both username and password key into a Website login page. No link can be provided for privacy reason.
For this, I had tried both the Xpath and CSS selector approach. However, each technique give me a different error.
For example, using the xpath approach as below;
user_id =self.browser.find_elements_by_xpath("//[@id='tcl_MainContentPlaceHolder_tcl_Username']")
user_id.send_keys( 'username' )
user_pw = self.browser.find_elements_by_xpath("//*=[@id='tcl_MainContentPlaceHolder_tcl_Password']")
user_pw.send_keys( '12345678' )
will output an error;
AttributeError: 'list' object has no attribute 'send_keys'
Whereas, using CSS selector as below;
user_id= WebDriverWait( self.browser, 20 ).until(EC.presence_of_element_located( (By.CSS_SELECTOR, 'tcl_MainContentPlaceHolder_tcl_Username.form-control.input-lg') ) )
user_id.send_keys( 'username' )
will output an error
selenium.common.exceptions.TimeoutException: Message:
I had play around with different xpath & css path, but, it does not provide any better result.
The full html/path to each of the username box and password are given below;
User Name
<div class="form-group m-b-tcl">
<input name="tcl$MainContentPlaceHolder$tcl$Username" type="text"
id="tcl_MainContentPlaceHolder_tcl_Username" class="form-control input-lg"
placeholder="Username" autocomplete="off">
<span id="tcl_MainContentPlaceHolder_tcl_UserNameRequired"
style="color:#CC0011;visibility:hidden;"></span>
</div>
Password
<div class="form-group m-b-tcl">
<span id="tcl_MainContentPlaceHolder_ctl00_PasswordRequired"
style="visibility:hidden;"></span> <input name="tcl$MainContentPlaceHolder$ctl00$Password"
type="password" id="tcl_MainContentPlaceHolder_tcl_Password"
class="form-control input-lg" placeholder="Password">
</div>
I really appreciate if someone can show where did I do wrong. Thanks in advance.