Unable to fill values into text box using autoit script with firefox? - mozilla

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

Related

ElementNotInteractableException while using selenium and python

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.

element not clickable for radio options

I am trying to find all elements by using find_element_by_xpath. In the below web elements, I am looking for these three elements separetely:
1. <label for="hw-log-mode-none" class="ng-binding">None</label>
2. <label for="hw-log-mode-session" class="ng-binding">Per-Session</label>
3. <label for="hw-log-mode-mapping" class="ng-binding">Per-Mapping</label>
<div class="field ng-scope" ng-if="!isTransparentMode && showNatPool && !policy.isIPv6" ng-show="policy.action == 'accept' && policy.nat == 'enable'">
<label class="ng-binding">Hardware Logging Mode</label>
<div>
<div class="radio-group">
<input type="radio" id="hw-log-mode-none" value="none" ng-model="policy['hw-logging-mode']" class="ng-pristine ng-untouched ng-valid" name="670">
<label for="hw-log-mode-none" class="ng-binding">None</label>
<input type="radio" id="hw-log-mode-session" value="session" ng-model="policy['hw-logging-mode']" class="ng-valid ng-dirty ng-touched" name="671" style="">
<label for="hw-log-mode-session" class="ng-binding">Per-Session</label>
<input type="radio" id="hw-log-mode-mapping" value="mapping" ng-model="policy['hw-logging-mode']" class="ng-valid ng-dirty ng-touched ng-valid-parse" name="672" style="">
<label for="hw-log-mode-mapping" class="ng-binding">Per-Mapping</label>
</div>
</div>
</div>
I can find element #1 and #2 in above list. But when I try to find element #3 using the same way:
elem = driver.find_element_by_xpath("//label[#for='hw-log-mode-mapping']")
I got this error:
Message: element click intercepted: Element ... is not
clickable at point (707, 508). Other element would receive the click:
... (Session info: chrome=77.0.3865.90)
You could try clicking the element using Javascript and see if that works around the error.
elem = driver.find_element_by_xpath("//label[#for='hw-log-mode-mapping']")
driver.execute_script("arguments[0].click();", elem)
If that doesn't work, you could try clicking the input element itself.
elem = driver.find_element_by_xpath("//input[#id='hw-log-mode-mapping']")
driver.execute_script("arguments[0].click();", elem)
Try this, Get list of all the elements as they have same class name as follow:
List<WebElement> elements = driver.findElements(By.xpath(".//label[#class='ng-binding']"));
Now create a method to select the radio options as follow:
public void selectRadioOption(String option){
if(option.equals("None"))
elements.get(0).click();
else if(option.equals("Per-Session"))
elements.get(1).click();
else if(option.equals("Per-Mapping"))
elements.get(2).click();
}
Call this method, pass the option whichever you want to select.
Hope it works for you. You should not find 3 different xpath if you can work with one.

Unable to turn on Autocomplete On

I've this page and there is an input text element(Enter PNR No):
<input class="form-control_custom input_text_custom" type="text" id="inputPnrNo" maxlength="10" value="" placeholder="Enter PNR No." onkeypress="return ((event.charCode >= 48 && event.charCode <= 57) || event.charCode == 0)" >
I've added autocomplete as in below:
<input class="form-control_custom input_text_custom" type="text" id="inputPnrNo" maxlength="10" value="" placeholder="Enter PNR No." onkeypress="return ((event.charCode >= 48 && event.charCode <= 57) || event.charCode == 0)" autocomplete="on">
But autocomplete is not turning on. What could be the problem?

How to set a position while we write a string into a file using PHP?

I want to write an attribute inside text field tag, in my file file.txt. Below code writes some content in file.txt,
$my_file = 'file.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);
Below is my form html code,
<form>
<input type="text" value="FIrst Name" />
<form>
I want to write a name attribute name="fname" as below,
<form>
<input type="text" name="fname" value="FIrst Name" />
<form>
How to set a position while we write a string into a file.

How to concatenate a variable to a string in smarty?

I've following smarty code:
{foreach from=$preview_data key=key item=value}
<input type="hidden" class="form-control" name="units_$key" id="units_$key" value="{$value.units}">
{/foreach}
I want to attach a string units_ to a value contained in variable $key. I tried above code but it didn't work. How to achieve this?
$key is just a variable, use the same syntax:
<input type="hidden" class="form-control" name="units_{$key}" id="units_{$key}" value="{$value.units}">

Resources