Codeception Html Attributes Error Messages - phantomjs

I'm working on a form field test, this test should check if an inputfield is not filled.
The inputfield has the required attribute like: <input type="text"
required="required" >
My problem is that the tag of Codeception $I->see('errormessage'); does not recognize the message of the required tag. Are there any suggestions?

Have you tried with:
$I->seeInField($field, $value);
or:
$I->dontSeeInField($field, $value);
If you need reverse. Can't quite understand what you actually need to check but one of these methods should help you, just change $field and $value with your data.

Related

Cannot Input Text into HTML input element using Robot Framework

I have HTML which looks like this:
<input type="text" name="USERNAME.DUMMY.DUMMY.1" value="" id="USERNAME.DUMMY.DUMMY" class="username" size="25" autocomplete="Off">
I am trying to insert text to this input element after loading it. Her is my Robot script:
Open Browser ${url} ${browser}
Sleep ${wait}
Input Text id=USERNAME.DUMMY.DUMMY ${text}
But it is never able to find the ID. I have tried the same with class and name attributes but none of them work. This element is not under an iFrame.
Any help would be appreciated !
Can you try
input text //*[#id="USERNAME.DUMMY.DUMMY"]

Non V-bind part of the V-Model

As we know v-model is two way binding. Which means it's combination of V-bind and maybe another attribute which I'm looking for and it updates the data. I have a input which it's value is sometimes custom and sometimes should be read from config based on another parameters.
What I need is an input with a v-bind:value/:value and another for update. I know I can do it with #change and a custom method But I'm looking for something easy, Bottom line is I want V-model without doing v-bind ! Thank You
EDIT: I did it with two input using v-if .
<input type="number" class="item-input" v-if="setting.keto_program=='custom'" id="protein_per_kilo" v-model="setting.keto_program_protein_density">
<input type="number" class="item-input" v-else disabled id="protein_per_kilo" :value="config.keto_programs[setting.keto_program].protein_density">
Anyway doing this using just one input feels better. Thanks
May be you can use computed hook.
computed:{
yourVariable(){
return someVariable/computation
}
}
you can use yourVariable inside your code that will act like v-model without doing v-bind.
yourVariable will be updated as soon as the variables of the return statement of this be changed or updated
Edited:
part of v-model for input tag
<input
v-bind:value="variable"
v-on:input="variable = $event.target.value"
>
or
<input
:value="variable"
#input="variable = $event.target.value"
>
found this via
Vue.js—Difference between v-model and v-bind

Using aurelia variable in html attributes

I want to dynamically set the input datetime step granularity using aurelia binding.
In my time.js:
timeStep = "1";
In my time.html:
The following works correctly:
<input type=datetime-local value="2017-01-01T00:00:00" step="1" value.bind="formParameters.timeFrom" >
${timeStep}
However when I try to set the step using my variable - it doesn't seem to work:
<input type=datetime-local value="2017-01-01T00:00:00" step="timeStep" value.bind="formParameters.timeFrom" >
${timeStep}
You can see I have lost the seconds granularity. When I inspect the element, it comes out as:
<input type="datetime-local" value="2017-01-01T00:00:00" step="timeStep" value.bind="formParameters.timeFrom" class="au-target" au-target-id="37">
Where timeStep should be "1".
To bind any HTML attribute to a property in your viewModel - you need to use .bind.
<input type=datetime-local value="2017-01-01T00:00:00" step.bind="timeStep" value.bind="formParameters.timeFrom">
Aurelia will assume anything in a .bind attribute is a property of your viewModel class and bind them accordingly. You can use .bind on any (as far as I know) HTML attribute.

TestStack.Seleno TickCheckbox not working

I have 2 forms that I am testing using TestStack.Seleno. Both forms have a checkbox that is mandatory. The first form has (including the checkbox) 5 fields. I can use TestStack.Seleno to create a passing test with valid data. I set the checkbox like this:
Input.TickCheckbox(f=>f.Accept,form.Accept);
On my other form which has 10 or so fields, when I try to set the checkbox to be ticked (using the same code) nothing happens. However when I try
var acceptCheckBox = Find.Element(By.Name("Accept"),new TimeSpan(0,0,0,50));
if (form.Accept)
{
acceptCheckBox.Click();
}
I get error "Element is not currently visible and so may not be interacted with"
Element is clearly visible and is not injected in using javascript.
I am using latest version of TestStack.Seleno from github.
Any ideas?
So I have managed to figure out what the issue is and have a work around, however I cannot explain why it works on the other form. The mandatory Accept field has html generated by mvc that looks like
<div>
<input class="check-box" data-val="true" data-val-mustbetrue="The Accept our field is required" data-val-required="The Accept our field is required." id="Accept" name="Accept" type="checkbox" value="true"><input name="Accept" type="hidden" value="false">
<label for="Accept">
Accept our Please accept our Terms and Conditions
</label>
<span class="field-validation-valid" data-valmsg-for="Accept" data-valmsg-replace="true"></span>
</div>
So you have the checkbox and hidden field both with id Accept, I suspect in code seleno is picking up the hidden field and setting value, so I updated my code todo
var acceptCheckBox = Find.Element(By.CssSelector("#Accept.check-box"));
acceptCheckBox.Click();
Now everything works.
Ismail

How to check if radio button is selected or not using Selenium WebDriver?

<div class="my_account_module_content">
<h3 class="my_account_module_content_title">
Mi Dirección 1
<br>
<span>Predeterminada</span>
<div class="selectCard_left">
<input id="17390233" class="default_shipping_address" type="radio" name="address" checked="true">
<span>Seleccionar como tarjeta predeterminada</span>
</div>
this is the HTML code
If radio button selected is true then print the class span value?
please help me..
In Java, this would do it:
if(driver.findElement(By.id("17390233")).isSelected()){
System.out.println(driver.findElement(By.xpath("//input[#id='17390233']/following-sibling::span[1]")).getText());
}
If the radio button is selected, then the text will show. If you want to use the text somewhere, I suggest you put it in a string instead:
String spanText = driver.findElement(By.xpath("//input[#id='17390233']/following-sibling::span[1]")).getText();
Hope this answers your question.
EDIT: Here is an update of other ways to try.
If the className default_shipping_address is unique (e.g. not used anywhere else on the page), you may try locating the element by className:
if(driver.findElement(By.className("default_shipping_address")).isSelected()){
System.out.println(driver.findElement(By.xpath("//input[#class='default_shipping_address']/following-sibling::span[1]")).getText());
}
If that class is not unique, maybe the DIV's className selectCard_left is?
if(driver.findElement(By.className("selectCard_left"))){
System.out.println(driver.findElement(By.xpath("//div[#class='selectCard_left']/span[1]")).getText());
}
If none of the classNames are unique, a complete xpath expression is required. If you still are unable to get that text, I refer to reading up on how to use xpath: http://www.w3schools.com/XPath/xpath_syntax.asp
I hope that you find this information useful.