I am trying to open a form having a DateTextField which must be populated with record from database. And I am having no luck of doing it. I already test my code this way :
dijit.byId("jurnal_date").attr("value", new Date(2011,1,1))
Just to test the basic way of setting a DateTextField. But the value won't get entered into DateTextField. What did I do wrong? Here is the DateTextField declaration:
<input type="text" name="jurnal_date" id="jurnal_date" required="true" dojotype="dijit.form.DateTextBox" />
Thanks!
Ah, I just resolved my own problem. Here is the answer :
newJournalDialog.show();
dijit.byId("jurnal_date").attr("value",dojo.date.stamp.fromISOString(jurnal.date))
So, we can only set the value of a DateTextField, after its dialog/form is shown.
Well, this is my conclusion after solving this problem :)
Thanks.
Related
I've been having trouble around finding elements by attribute/property. Following UI visible example:
<input tabindex="0" placeholder="www.stuff.com/example" type="text" id="sub-selector-37" class="form-control" value="">
The unique piece is the placeholder text.
I've tried the following:
And waitFor('input[placeholder=www.stuff.com/example]') - Error
And waitFor('input[placeholder="www.stuff.com/example"]') - Error
And waitFor('input[placeholder='www.stuff.com/example']') Finds nothing
Also tried a more direct input approach:
Then waitFor('{}Something else')
Then input('input[placeholder=www.stuff.com/example']', 'Stuff')
I'm hoping this is just good old PEBKAC on my part. Any suggestions would be greatly appreciated.
Here you go, use double-quotes and nest single-quotes:
And waitFor("input[placeholder='www.stuff.com/example']")
A tip: use the debugger and you can experiment with things like highlightAll('input') and narrow down what works: https://twitter.com/KarateDSL/status/1252817691963830272
I'm using Selenium IDE to fill out a form. It's not my website, so I cannot change the code. I've managed to do most of the things, the only input I'm struggling to put the data on is this one, which uses a datepicker/calendar instead of the a "traditional" input:
<input class="rich-calendar-input " id="dtEmissaoInputDate" maxlength="10" name="dtEmissaoInputDate" onkeypress="IsNumber(this,event);mascaraData(this,event);" size="15" style="vertical-align: middle; " type="text" value="09/10/2019" readonly="readonly">
Since I'm new to Selenium, I'd like to know how to change the value of that input using the data I have on an array. I've already searched older questions to see what I could find, but most of the answers use older syntax.
Thanks in advance for the answers.
You can use Javascript to accomplish this. You can call executeScript to modify the value attribute of your desired element.
executeScript("document.getElementById('dtEmissaoInputDate').setAttribute('value', 'yourTextHere')");
You can also pass the element in directly:
executeScript("arguments[0].setAttribute('value', 'yourTextHere')", inputElement);
Hope this helps a bit.
Found the solution. Based on #Christine's answer, I was to solve the issue using Javascript and run script command:
"command": "runScript",
"target": "document.getElementById('dtEmissaoInputDate').value='01/01/2018'",
I have an input box with placeholder.and I am setting the value in this field via Session variable in php.
This is the code which I have written :
<input type="text" value=<?=$_SESSION['no_of_persons']?> name="no_of_persons" id="no_of_persons" placeholder="No. of Person(s)" maxlength="3" />
and when I run this in firefox and watching the code in Firebug this following code is coming :
<input id="no_of_persons" type="text" maxlength="3" placeholder="No. of Person(s)" name="no_of_persons" value="7">
Problem is I am not able to see the value in textfield in the web page.
I go to firebug and edit html in firebug. What I do is when I press an space key at the end of input tag i.e after value="7" then the value 7 becomes visible on web page.
I am not getting why the browser automatically changing the sequence of attributes of input tag and also I already had closed input tag then why the browser not closing it.
I tried it in other browser also like safari,chrome but not working.
Please help me to get rid off this problem.
Thanks in advance!!! :)
I have to identify a check-box using the label which follows it.
the code is the following:
<input type="checkbox" checked="" value="1" id="email-100-100" name="email-100-100">
<label for="email-100-100" class="firefinder-match">Email me when someone asks me to set a flag</label>
<br>
</td>
I tried
Target://following-sibling::label[text()="Email me when someone asks me to set a flag"]
Target://preceding-sibling::label[text()="Email me when someone asks me to set a flag"]
but in both cases selenium finds the text of label but not the check-box.
Could somebody help me in this?
Thank you in advance
Try
Target://label[text()="Email me when someone asks me to set a flag"]/../input[#type='checkbox']
It will work as long as the containing element of the label and checkbox only has one checkbox in it.
You can also find a label that contains text, which is useful for a partial match. In my case I had something like this:
<label for="blah">
<input name="blah" id="blah" type="checkbox" />
Store Locator Plus
</label>
The accepted solution worked for the specific example cited but requires an exact match. Since this comes up on the top of search results I figured I'd present the partial-match solution here as well.
For Selenium IDE you can set a target like this:
//label[contains(text(),'Store Locator Plus')]//input[#type="checkbox"]
The contains function was required because the label text had an HTML element as well which thwarted the //label[text()='Store Locator Plus'] target.
I've created a DateTextBox like:
<input dojoType="dijit.form.DateTextBox" constraints="{max: Date.now()}" id="startDate" />
When the page loads there is no value in the field. I would like the value to default to today. Is there a way to handle this? I know I could use the "value" attribute and set it in the declaration, but that only allows me to put a static date in the field, not a dynamic date.
It would also be good if the solution works with a form reset too.
Thanks for the help!
The parser supports the "now" keyword, so you could do:
<input dojoType=dijit.form.DateTextBox value="now">
Of course, for programmatic creation you would simply do:
new dijit.form.DateTextBox({value: new Date()})
Your solution:
<input dojoType=dijit.form.DateTextBox value="now">
If you want to make the date other than today:
<input dojoType=dijit.form.DateTextBox value="now" constraints="{max: new Date()}">