Angularjs e2e test - How to use input(name).enter(value)? - testing

I'm so new in writing scenarios for e2e testing in Angularjs. I want to write a scenario to test the login. I have a form which has an email field as follow:
<input type="email" placeholder="Enter your e-mail" name="email" ng-model="form.email" value="" required autofocus >
And in my scenario I'm having having the following line which tries to pass some email address to that input field:
input('form.email').enter('blabla#blabla.com');
But unfortunately I'me getting the following error after running the test:
6ms input 'form.email' enter 'blabla#blabla.com'
Selector [ng\:model="form.email"] did not match any elements.
Any suggestion?

check to make sure that you have:
browser().navigateTo('/');
Without navigating first angular does not have any reference to the DOM.
You can also use :
pause();
To see exactly what the browser is displaying at the given time when running an e2e test.

Related

Not able to use attribute selector in cypress

My HTML fragment is:
<label class="email">
Email
<input data-test="email" type="text" v-model="curMember.email_address">
</label>
Then in my cypress test the following 'GET' does not work (using attribute selector):
cy.get('[data-test="email"]').should('have.value', 'a#test.com')
the above times out trying to find the element but the folowing does work (using a class selector)
cy.get('.email>input').should('have.value', 'a#test.com')
Can anyone tell me what my problem is?
I am not sure that cypress provides of getting value from NON-class
but take a look at this https://docs.cypress.io/api/commands/get.html#Selector
for the first example, you can only check the length
cy.get('[data-test="email"]').should('have.length', '10')

How to attach multiple file in Laravel 5 Codeception

I would like to attach several files to run my test in Laravel 5.2 and Codeception 2.1.6.
I have an input :
<input type="file" id="shapefiles" name="files[]" multiple>
When I try to attach some files to it like this :
$I->attachFile('files[]', 'districts/shapefiles/admin2.dbf');
$I->attachFile('files[]', 'districts/shapefiles/admin2.shp');
I get the error :
[TestRuntimeException] None of form fields by files[] were not matched
I can't reproduce the behaviour I would like to test here.
I didn't find any advice on my friend Google. How could I manage to do that ?

Why Behat/Mink cant't find input field by ID, only by name?

I am testing page with behat and filling form.
I have two password inputs in page html.
First is on top:
<input id="login_password_0" class="form-control " type="password" placeholder="Slaptažodis" autocomplete="off" name="password">
Second at the bottom:
<input id="password" class="form-control validate" type="password" value="" name="password">
Then I run behat/mink test with:
And I fill in "password" with "test"
It fills first one and I need second to be filled.
How to understand documentation, that element can be found and filled by 'id|name|label|value'.
P.S. Changing HTML is not an option.
Haven't tested but it looks like that Behat is performing a task only once. He has no idea that there could be two elements with the same name. "Name" attribute should be unique for one form. Otherwise, you'll be posting two elements with the same name.
Without fixing your HTML nothing is possible, unless you implement your own test which overcomes this issue. Now "password" is both "id" and 2x "name" attribute. Selector should be unique.

placeholder input field not showing value?

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!!! :)

locating html elements with selenese in a test

while writing some acceptance tests for my webapp (playframework based),I got confused by the usage of some selenium commands.
In my html page,I have a submit button like this
<input type="submit" id="removecartitem" value="remove"/>
to locate this,I used
assertElementPresent(id='removecartitem')
however,this fails,
assertElementPresent id='removecartitem' false
The selenium documentation says
id=id: Select the element with the specified #id attribute.
but,if i simply put
assertElementPresent('removecartitem')
Then,the test is executed correctly.This is the source for confusion, since the default way is to select the element whose name attribute is 'removecartitem' ,and I haven't mentioned any name attribute in my html
Any idea why this happens?
It looks like you need to remove the single quotes according to the documentation you provided...e.g:
assertElementPresent(id=removecartitem)