Ok, I'm having issues with my Test Runner where it is filling out the fields on the form but when I then submit the forms it refers to these fields as blank.
If I write to the field using element('some_element).val('some_val') this works fine.
If I then check the field with expect(element('some_element').val()).toBe('some_val') it passes without any problem
BUT
If I submit this form, it returns saying all these elements are empty. However I can change just one character manually and it accepts it without any issues.
Could anyone explain what would cause such an issue? And also any possible solutions on how to get round it?
The issue was with KendoUI and not the test runner.
Related
I am facing problem of testing jmeter/Webdriver for a webapp which has Knockout framework installed. I fill all the form fields OK but when run click search button it displays the error that required fields need not to be empty. I checked all web element value are not empty. As my understand Knockout is not activated to bind Web elements with DataModel from Knockout. I used wait WDS.browser.manage().timeouts().implicitlyWait for webpage fully loaded/ajax calling or event being fired but without any success. I Do you have any experiencing and solution for testing this kinds of webapp?
thanks
It might be the case you need to trigger a certain JavaScript event in order to "tell" the web application that you finish the input, i.e. onkeyup or onblur which is not being automatically called by Selenium's sendKeys() function
You can use i.e. WDS.browser.executeScript() function to send the event(s) which indicate that you filled in the form(s). Check out The WebDriver Sampler: Your Top 10 Questions Answered article to learn how to call scripts, use Waits, etc.
I've been trying to figure this out using various different methods. I'm trying to create a script/bookmark or some type of quick action to open a browser tab or window with a specific URL, and automatically log me in using my credentials. I'm not all that concerned about security for this at the moment.
At first I figured I'd try to use a javascript bookmark to do this, but nothing I found in my research worked. Next I tried to create a bash script, but I couldn't figure out how to send the credentials in via the terminal. Most recently, I literally copied the source code of a site, created a local file and tried to hack together something where I could prefill the form data with credentials and use JS to submit the form, and I've gotten close with this, but for some reason when I use the JS submit function, it errors out and says that the username and password are invalid. But when i turn off the submit function and manually click "log in" on my local html page, it works as expected. I want this to be a one click process, so the idea of using onload/submit or something to that affect is really important to me.
The site I'm testing with has a Rails backend and my next attempt might be trying to use POST to do what I'm thinking, but that's currently outside of my level of knowledge on the subject.
Anyone answering: i do not want to use a password manager to accomplish this.
My requirement is that i will either be able to a) run a script or b) use a 1-click option to do this per website. Ideally i'd be able to set this up in a sort of programmatic way to do this with multiple sites, but I'd be happy with 1 at the moment.
i know similar questions have been answered before, but I haven't been able to use information from those posts (the ones I've seen anyway) to figure out a good way to do this.
Create a bookmark for the current page you have opened.
Edit the bookmark
Change the value for the URL to something like this.
(javascript:(function(){CODE_GOES_HERE_FROM_BELLOW})();
find the field for username and password on the page.
Given example for hotmail
var inputs = document.getElementsByTagName('input'); for(var i=0;i<inputs.length;i++){if(inputs[i].name === 'passwd'){inputs[i].value = 'YOUR_PASSWORD'}else if(inputs[i].name === 'loginfmt'){inputs[i].value = 'YOUR_USERNAME'}}; document.getElementById(document.getElementsByTagName('form')[0].id).submit();
OR
try out casperjs.
The proposed solution didn't work for me and rather than spending tons of time installing a testing framework that I'll never use other than for this purpose, I decided to try to do this another way.
First, I found out that the reason my JS wasn't working before is because the site did not allow a JS submit to be done, or atleast that's what it seemed to be when I got this error: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience"
The javascript I was using was in fact working, just not submitting. I used the following code to fill the fields (using "Class Name" elements on the page since there was no name or ID):
document.getElementsByClassName('username')[0].setAttribute('value', 'user');
document.getElementsByClassName('password')[0].setAttribute('value', 'password');
As I mentioned, the problem was when I tried to use JQuery to submit the form: document.getElementsByClassName('loginForm')[0].submit();
Which is when the above error cropped up. I can't really say for sure whether this is the root of the cause, but the page does submit, but I get an invalid username/password error when I do
I haven't figured out a great way to get around this just yet, but my short-term, "hacky" solution was to use Applescript to send a return keystroke to the browser to submit the form. I'd ideally like to figure out how to get the submission to work using JQuery, but I'm not sure how to get around it.
I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing
I'm testing (using Selenium) a site containing a slickgrid.
To find the correct field to enter a value, I have to apply a filter, and then double click the field to enter the data.
The problem is, that after applying the filter nine out of ten times Selenium ends up with an exception that the element is no longer attached to the DOM, or is not present in the cache anymore. One out of ten doesn't fail on this point.
I've tried about every bit of advice I can find on this issue, but none has brought any sufficient help. Waiting an looping until the element is present, visible etc. doesn't work.
So: is there a way to have Selenium locate an element in a slickgrid after the page has changed because of a filter action?
Thanks!
Options for a dropdown on a webpage I am testing are dependent upon the values supplied for earlier textboxes and selects (E.g. based on the currency and amount specified, dropdown for product will show appropriate values. With no values, the supplied the dropdown is blank.).
Now, although I have provided the values for currency and amount, the product dropdown is still blank. It is not fetching the filtered values based on earlier data supplied. I am using Selenium server (2.24.1) and writing scripts in Java in Eclipse with TestNG and testing on IE8.
When inspected, the dropdown is no different from others, only its options change based on the values of other elements on the page. The web application is developed in Java (Wicket framework).
The Selenium code:
selenium.select(ownerBranch, "label=4521 - Branch one");
selenium.select(currency, "label=SEK - Swedish kronor");
Thread.sleep(sleep);
selenium.type(amountSantioned,"100000");
Thread.sleep(sleep);
selenium.click(chooseLoanTermBymatDate);
Thread.sleep(sleep);
timeNow=Calendar.getInstance();
timeNow.add(Calendar.DATE,+360);selenium.type(maturityDate,dateformat.format(timeNow.getTime()));
Thread.sleep(sleep);
selenium.type(amountSantioned,"100000");
Thread.sleep(sleep);
selenium.select(serviceDelChannel, "label=BackOffice");
Thread.sleep(sleep);
selenium.select(product, "label=");
Thread.sleep(sleep*2);
selenium.select(product,"label=LN7292 - Consumer loan for Year2026");
Thread.sleep(sleep);
I'm not going to try to reproduce the issue (if you can point me to a publicly visible site with similar behaviour, I might test it), so I'm only taking a guess here:
Since Selenium RC is written in pure Javascript and "only" firing change events on selecting values from drop-downs, Wicket is probably waiting for something else or relying on a completely different mechanism.
Things you can try:
Use Selenium WebDriver. Selenium RC has been deprecated for over a year now, because it had serious technical limitations (you might have just bumped into one) that are now solved by WebDriver. Also, you won't ever have to use Thread.sleep() again (although I'm almost sure it could be got rid of even here, mostly). This solution is the most painful, but is almost guaranteed to work well, because WebDriver behaves like a real user.
Call selenium.fireEvent() on all the input elements you're interacting with. Useful events might be focus, blur, maybe even click in between them.
Calling selenium.keyPressNative(String.valueOf(KeyEvent.VK_ENTER)) (presses Enter natively) after you every change of a dropdown. If the changed dropdown is not focused before this, you might need to focus() it beforehand.
The painful way that tries to simulate user's behaviour as close as possible instead of using JS methods: Instead of using select(), try to focus() a dropdown element, then select one of its options by pressing Down arrow repeatedly, then Enter.