I am trying to automate login to a website (http://www.primecbdatabase.com/). It's source code is as follows
<p><label for="username">User ID</label> <input type="text" name="user_id" value="" onchange="javascript:replcodeid()"; size="6" maxlength="50"></p>
<p><label for="Password">Password</label><input type="password" name="password" id="password" value="" size="6" onkeypress="return SplChar1(event);" onchange="javascript:replcodepwd()" maxlength="16" ></p>
<p class="btn" style="margin-bottom:0;"><a onmouseover="self.status='PRIME Database';return true" href="javascript:submit1()"><img src="images_NSE/login-btn1.png"></a></p>
<p class="password">Forgot Password?</p>
It works correctly when dealing with the username input as shown below
inputElement = driver.find_element_by_name('user_id')
inputElement.send_keys(username)
But when I am trying to do the same for password (as shown below) it throws the ElementNotInteractableException. Looks like I am having trouble with send_keys to transfer the password to the input box.
inputElement = driver.find_element_by_name('password')
inputElement.send_keys(password)
I tried changing find_element_by_name to find_element_by_id, it still doesn't work. Kindly help me with it.
You need to click on the textbox before type.
driver.find_element_by_id("password").click()
driver.find_element_by_id("password").send_keys("123")
I have tried and am able to type a password using a script.
Related
<div _ngcontent-ucs-c11 class="order__form--name"> ==$0
<label _ngcontent-ucs-c11 class="order__form--label">Symbol</label>
<!---->
<input _ngcontent-ucs-c11 class="form-control form-control-sm ng-untouched ng-pristine ng-invalid" formcontrolname="symbol" type="text" typeahead-editable="false" typeaheadoptionfield="symbolName"typeaheadoptionslimit="50">
<!---->
<!---->
</div>
I'm trying to send_Keys in selenium (python) but am unable to locate the text Web Element. I tried locating by class and xpath:
drive.find_element_by_class_name("form-control form-control-sm ng-pristine ng-invalid ng-star-inserted ng-touched")
driver.find_element_by_xpath("//input[#class='form-control form-control-sm ng-untouched ng-pristine ng-invalid')]")
The class changes from "form-control form-control-sm ng-pristine ng-invalid ng-star-inserted ng-touched" to "form-control form-control-sm ng-untouched ng-pristine ng-invalid ng-star-inserted".
I'm not sure if this is significant but, in addition to this the "_ngcontent-ucs-c11" also changed to "_ngcontent-uji-c7" and might change again to something else.
Also, is it anyway related to typeahead-editable="false" attribute inside input?
For the dynamic element you can use regular expresions.
driver.find_element_by_xpath("//input[contains(#name,'sel')]")
or
driver.find_element_by_xpath("//input[starts-with (#name,'Tut')]")
or
driver.find_element_by_xpath("//input[ends-with (#name,'nium')]")
Pick one that suits in your case(you will use (#class,'Tut')). And read more on https://www.tutorialspoint.com/how-to-use-regular-expressions-in-xpath-in-selenium-with-python
I have a form that spans multiple tabs in a TabStrip control. However, when the form is validated (e.g. f.valid), not all controls are considered when the validation is evaluated.
For example, if an input field is on tab 1 that is marked as "required" and the save action is called when the focus is on tab #3, the form will read as invalid since the required field is not in view. If the focus is on Tab #1, all works as expected.
I understand why this behavior is occurring, but I wanted to see if there was any suggested workaround.
Thanks!
Update
I created a plunkr that shows the basic issue. It is actually a little backwards from the problem I described, but it shows how the form ignores the fields on tabs other than the one displayed during validation: Plunkr Example
The template code looks like this:
<form #f="ngForm" (ngSubmit)="save(f)">
<kendo-tabstrip>
<kendo-tabstrip-tab [title]="'Paris'" [selected]="true">
<ng-template kendoTabContent>
<input type="text" name="controlOne" id="controlOne" [(ngModel)]="myModel.controlOne" required>
</ng-template>
</kendo-tabstrip-tab>
<kendo-tabstrip-tab [title]="'New York City'">
<ng-template kendoTabContent>
<input type="text" name="controlTwo" id="controlTwo" [(ngModel)]="myModel.controlTwo">
</ng-template>
</kendo-tabstrip-tab>
<kendo-tabstrip-tab [title]="'Tallinn'">
<ng-template kendoTabContent>
<input type="text" name="controlThree" id="controlThree" [(ngModel)]="myModel.controlThree">
</ng-template>
</kendo-tabstrip-tab>
</kendo-tabstrip>
<button type="submit">Save changes</button>
</form>
<div>
Valid when saving: {{ isValid }}
</div>
The bottom line for text-field is shown a bit above.
No CSS used ...
<div class="mdl-textfield mdl-js-textfield">
<input class="mdl-textfield__input" type="text" pattern="[0-9]*" id="phone">
<label class="mdl-textfield__label" for="phone">Phone</label>
<span class="mdl-textfield__error">Digits only</span>
</div>
<form action="#">
<div class="mdl-textfield mdl-js-textfield">
<input class="mdl-textfield__input" type="text" id="demo-input" />
<label class="mdl-textfield__label" for="demo-input">UserName...</label>
</div>
</form>
Take a look at what I got
Take a look at the answer which i posted for the below stackoverflow thread.
Material Design Lite - Bottom Line in text field has a slight gap with colored line
In PHPStorm, when creating a snippet, you can do something like this:
<!-- $VALUE$ Form Input -->
<div class="form-group">
<input type="text" name="$NAME$" class="form-control">
</div>
With variables and such, so you can easily write a value. I'm wondering how to do the same thing with Sublime Text 3. This is what I have in my CDATA tag:
<!-- $VALUE Form Input -->
<div class="form-group">
<input type="text" name="$NAME" class="form-control">
</div>
However, it's not working.
Unfortunately, the only variables that are available in snippets are specified in the docs under snippets environment-variables, as well as any you declare in a .tmPreferences metadata file, or in a .sublime-options file. However, you can have predefined values in snippets. For example, this snippet:
<snippet>
<content><![CDATA[<!-- ${1:VALUE} Form Input -->
<div class="form-group">
<input type="text" name="${2:NAME}" class="form-control">
</div>$0]]></content>
<tabTrigger>form_group</tabTrigger>
<scope>text.html</scope>
</snippet>
gives this result when triggered:
You can then hit Tab and the focus will move from field 1 to field 2:
and again to move to the exit point $0:
i am unable to fill values into text box ?i have tried following code..``
$url = "file:///C:/Users/Desktop/HTML.html"
$formID = ""
$formUID = "username"
$uName = "srv.iloadmin"
$formPID = "password"
$pwd = "SeR^ER#iL0"
$formSubmit = "ID_LOGON"
Run(#ProgramFilesDir & "\Mozilla Firefox\firefox.exe " & $url, "", #SW_MAXIMIZE)
_FFSetValue($uName,$formUID,"id")
_FFSetValue($pwd,$formPID,"id")
HTML script username is:
<input autocomplete="off" class="textfield" name="username" id="username" size="30" onkeypress="return checkEnter(event);" type="text">
Password:
<input autocomplete="off" class="textfield" name="password" id="password" size="30" onkeypress="return checkEnter(event);" type="password">
You need to take a closer look at Firefox UDF
Here is a simple example:
#Include <FF.au3>
_FFConnect()
If _FFIsConnected() Then
_FFOpenUrl("http://www.example.com/news/811")
_FFLoadWait()
_FFClick(".forms[2].elements[0]")
_FFLoadWait()
EndIf