Cannot submit webform with dalek js - dalekjs

What is the correct way to click an input element using Dalek JS?
<input type="submit" name="submitButton " value="Next Page" id="submitButton" class="btnSubmit">
I've tried to submit the form using .submit('#formName') or just .submit() but this doesn't work (i'm assuming it's because its an asp.net webform)
I've also tried using .click('.btnSubmit') which works fine when using PhantomJS, but not when using the using the dalek-browser-chrome.
Any ideas?

interesting issue; first of all, I prefer submitting forms using a click on the submit button because this, in 90%, is the case when a "real" user submits the form.
So, in my humble opinion, this should be the way a Dalek test should handle form submits in most cases.
The interesting part of your question is, that it works in PhantomJS, but not in Chrome. I never seen something like this behaviour before. I encourage you to set up a reduced testcase, may it be a form with just one textinput field & a submit button.
If that works, try to add more elements to the reduced testcase that are also part of your failing testcase. If you hit the point where it stops working, great, we can then start & debug from that point on.
Additionally, if you start DalekJS with the additional -l 5 parameter like so dalek myTest.js -b chrome -l 5 that will make Dalek extremely chatty & output all the communication between Dalek & the Browser. Please check if any security or privacy relevant data is in there & mask it. Please then go ahead & post this here or send it to me via mail (dalekjs#asciidisco.com).

Related

Nightwatch Cannot Find/Click on Dropdown Option

I'm a backpacker and a programmer, trying to use the second skill to find openings in a full campsite. Rather than crawling fro scratch, I'm using the end-to-end testing framework nightwatch.js to navigate for me.
I've hit a roadblock, because nightwatch is having difficulty finding a specific element using css selectors.
Here are the elements and page:
Here is my test code:
Previous Attempts
My test code will click on the selection box with #permitTypeId. It will see that #permitTypeId option is visible. It will not see or click on any of the options when more specific values are specified. The five .click()'s are all css selectors I've already tried. None of the options are set to display:hidden or display:none. I have also tried all of the above without the .waitForElementToBeVisible() just in-case the waiting causes the dropdown to hide.
I've successfully clicked options from different dropdown menus on this website without any problem. Just this one is causing a headache.
The tests are running with the most current Selenium server and Firefox on Mac Yosemite.
tl;dr
Nightwatch.js/Selenium won't click on something from a dropdown menu.
The Path...
Cory got me thinking about jQuery and native DOM manipulation. Tried going that route and was successful selecting the correct option using Selenium's .execute() function:
.execute('document.getElementById("permitTypeId").options[1].selected=true')
However, it was not triggering the onchange event.
Saw this post which made me start thinking about using key-strokes and this one which suggested using arrow-keys to navigate down a <select> element to the option, then hitting enter.
...to the Solution
.click('select[id=permitTypeId]')
.keys(['\uE015', '\uE006'])
I've found that this is an issue with Firefox. Chrome and PhantomJS operate well clicking <option> tags.
you should be able to click like this way
browser.click('select[id="permitTypeId"] option[value="1451140610"]')
Additionally I was able to add a .click event for the specific option once I did a .click for the select. see my example below:
.click('select[name="timezone"]')
.pause(1000)
.click('option[value="America/Chicago"]') //selects the option but doesn't click
.pause(5000)
.keys(['\uE006']) //hits the enter key.
another solution:
.click('select[id="permitTypeId"]')
.waitForElementVisible("option[value='1451140610']")
.click("option[value='1451140610']")
Very simple way is to use .setValue('#element', 'value of option')

Visual Foxpro attempting to .click() a submit button on web or .submit() the webform - failing

I am programming in Visual Foxpro. I tried to programatically .click() at the submit button. It used to work, but now it triggers nothing. Alternatively I tried to .submit() the form. This too triggers nothing. But if I click the submit button at the website, it works perfectly. Can anyone help me out? arunkasi.co#gmail.com
My coding as as follows:
declare Sleep in kernel32 integer nmilliseconds
WebMain = CREATEOBJECT("InternetExplorer.application")
WebMain.navigate("https://epayment.hasil.gov.my/fpx/one.php")
WebMain.visible = .t.
DO WHILE WebMain.busy .OR. WebMain.readystate#4
Sleep(300)
ENDDO
WebMain.Document.Forms("LogonForm1").jenis_id.selectedindex = 1
WebMain.Document.Forms("LogonForm1").no_id.Value = "123456781234"
WebMain.Document.Forms("LogonForm1").kapca.Value = "56789"
WebMain.Document.Forms("LogonForm1").cmdSubmit.click() && IT DOES NOT WORK !
WebMain.Document.Forms("LogonForm1").Submit() && ALTERNATIVELY, THIS TOO DOES NOT WORK !
Most likely cause of your change in behavior is an update to Internet Explorer, wherein they improved the security model to keep malicious websites from injecting unwanted behavior into them.
See if the website you are attempting to reach has an actual web service that applications can use to send POST messages via HTTP instead of using a web page, (such as using the MSXML.XMLHTTPRequest object). If that website is your company's, creating a proper web service is a far better use of time than automating internet explorer through FoxPro.
But, if that's not possible, I believe you can adjust your code to use the IE-specific fireEvent method.
Add a parameter to click() or submit(). This will work:
WebMain.Document.Forms("LogonForm1").cmdSubmit.click(1)
or
WebMain.Document.Forms("LogonForm1").Submit(1)

before closing the Application browser should prompt conformation

I have a small requirement..
if the user dint sign off or log off then he try's to close the browser IE clicking on 'X' (top right of IE or Firefox browser ) then i need to ask a conformation message like "Are you sure you want to close ?" ...
I am using Master page in my application and i tried the event : "window.onbeforeunload " in my master page its works fine, shows an alert(conformation) message. but if i press back button on the browser(IE on IE or Firefox) then also its firing(but it should not) is there any way to full fill my requirement ..I hope i had explained u clearly...if not pl z let me know........
what i mean to say is.. if the Session("USerid") is active or if it contains any value ie.
Session("USerid")="XXX"
at that moment if user trys to close the browse(click in 'X'/Close button browser either IE or Firefox ) it should give prompt a message "are u sure do u want to close?"..
Its all about design steps - but the close and the back button is the same, the close the page, so maybe its impossible to have them all together.
To open, close your script you can make a simple trick. Place them inside a literal and open or close it.
<asp:literal run="server" id="txtCloseAlert">
<script>
... you code here ....
</script>
</asp:literal>
and on code behind.
txtCloseAlert.visible = !string.IsNullOrEmpty(Session("USerid"));
I've looked into this recently and there does not appear to be a standard / consistent way to do this cross-browser hence you back-button problem.
On IE at least you get an event object passed as a parameter to the onbeforeunload method that you can use to get the mouse position, but in FireFox you don't and you would need some other way to determine whether a confirmation is required. It is quite posible that you could get the mouse position in some other way as I haven't looked into that. Point is that if your mouse is not on your form you probably want a confirmation.
You can look at this SO question:
Prevent browser from closing in asp.net
Or do an Internet search on 'onbeforeunload prevent browser closing'.
In your case a synchronous ajax call can be made to the server to do the test.
HTH

asp.net linkbutton client-side problem

I have this linkbutton with post-back disabled ... I should have done it with an html control but just did it that way .. It is toggling a language bar on top (marara.com.tr - language link)
It needs to be clicked twice in order to get the div to fade-in. I can correct the problem but just want to know why it behaves like that. .. in the first click it adds a # sign to the address bar then on the second click it does what it is supposed to.. any leads?
thanx in advance
Emre
I had a similar problem. It depends on the browser you are using (This occurred when I was using Firefox but not when I was testing in IE6). It seemed like the browser looks at the URL and sees that nothing has changed (except the #...) so it doesn't reload the URL, causing the #... not to register. You can trick it into thinking the query string has changed by adding a '&' before the '#' so that you add &#... to the URL.

Asp.net and JavaScript pop up windows

I am writing an intranet application and am considering the use of a pop up window. I am not worried about accessibility since it's an intranet app.
The scenario is such as I need to be able to have the same code be used in a server page as well as in the middle of a process; which is why I decided when using it in the middle of the process, it's best to have it as a pop up window to running out of the real estate on the screen.
Any thoughts on this? I am hesitant to use a pop up window in such a manner as I usually only use it for error messages.
I don't completely understand what you're trying to do, but I think a popup window might be somewhat of an issue if the user's browser automatically blocks popup windows. Plus, if you were trying to run a process in the popup window, the user could close it and no longer have a way to check on the process.
Would it be possible to use Ajax to call back to a web service that gives the page information about the process? You could give the user a way to make the Ajax call to check on the status of the process or just have it continually polling in the background.
Edit:
You said you weren't too familiar with Ajax. For the most part, there are libraries to handle all the of hard details. I'll recommend jQuery because that's what I've been using for a while now.
If you go the Ajax route you'll be able to contain everything on one page and make the updates you need to make when the Ajax call is successful. Depending on how you write the code, it should be pretty reusable if you do it right. It really depends on how specific the your needs on each page.
Take a look at the jQuery documentation though. It may have what you need already built into it. Otherwise, someone else might be able to suggest some reasons why their favorite JavaScript library works better for what you're trying to do.
I think you might want to do something like this:
Inside of the parent page:
<input id="btnShowModal" runat="server" type="button" value='Show Modal' onclick="ShowModal()" />
function ShowModal()
{
var retVal = window.showModalDialog("MyPopup.aspx?param1=value","","center=yes;dialogWidth=200px;dialogHeight=200px;status:0;help:0")
if(retVal != "" && retVal != undefined)
{
//This code will be executed when the modal popup is closed, retVal will contain the value assigned to window.returnValue
}
}
Inside of the modal popup:
<input id="btnSave" runat="server" type="button" value='Save' onclick="Save()" />
function Save()
{
window.returnValue = "Whatever you want returned to the parent here"
window.close()
}
The usual argument against popup windows is that they are unreliable. The user may have disabled script initiated popups, I know I have.
In a controlled environment, such as an inranet, you may be able to be guaranteed that this is not the case, but even so, why risk it, there is an alternative.
Instead of popping up a new window just insert a new, absolutely positioned <div> into the document and insert your content into that using ajax or even an <iframe>. There are lots of examples/libraries on the web.
Thickbox for jQuery for example. There are of course scripts that don't require libraries.
I generally use a div with a z-index and absolute positioning; the .show() can be written and called on demand, it would have a button to .close(), and AJAX can make it seem modal so it must be clicked to close if you so desire. Then again, I hate messageboxes.
I was trying to avoid AJAX, simply because I have never used and don't have the time frame to learn it now. However, I am not totally opposed to it.
In short what I need to do is for the pop up window interact back with the page. Imagine that on the page I am building the links of the chain. Each link has unique properties. When user clicks on "ADD LINK" button, I was thinking have a pop up window with the little form and a Save button. The only issue with this is that a pop up needs to interact with the page; we need to know when something has been saved or not saved.
A div on the same page is one way. A pop up is yet another way. Another catch is that this code (adding new link) needs to be reusable, because I am also going to have a page that just creates new links.

Resources