finding download box element with capybara in cucumber test - cucumber

I have a link that downloads a file. As I click the link it displays dialog box with "save" and "open" option and "Cancel" and "OK" button. I want to find "OK" and "Cancel" button for cucumber test.
I took help from below link but didn't helped much.
How to test a confirm dialog with Cucumber?
**features code**
And I want to click "OK"
**steps code**
Then /^I want to click "([^\"]*)"$/ do |option|
retval = (option == "OK") ? "true" : "false"
page.evaluate_script('window.confirm = function() { return true; }')
page.click("OK")
end

The issue is that the dialogue you are talking about is not actually a part of the webpage at all. its part of the browser. Really, that part of the user interface it outside the control of the webpage.
All you can test is the webpage UP to the point of requesting the download, what the browser does with that request subsequently is not something you can script with cuke.
Sorry.

Related

How to locate default dialog for detail page?

I successfully display a dialog on detail page thanks to guidance from how do I customize dialog to the detail page of an answer set?. But yet I am unable to customise the dialog shown on the detail page, "Here what i found"
Would love to know where could i find out the concept/dialog that is relate to the default dialog on detail page, based on the debug console? or there is others ways?
[Extra infomation] I display detail page with layout match,
}else-if (size(this.audioItem)==1){
layout-match (this.audioItem){
mode (Details)
}
}
It success. But when i customise the result view's message,
message{
if (size(this.audioItem)==1){
template ("Can?")
}
The message come out 'Here what i found'.
The default dialog part might be a bit confusing, there is no need to do dialog model in your case. To replace the default "here is what I found", just use the message child-key in any view model.
For example, the following would display "In result view" instead of "here is what I found"
result-view {
match: TextName (this)
message ("In result view")
render {
if (size(this)>1) {
To check the complete example, download capsule from GitHub.

If else not read properly after changes made to any document

I have a button in a form where I'm using If else to check whether in list of document in view, "IF" any document with status "Lock", I will prompt messagebox "Complete PC Inspection First!". So
At first, after the button is click, and code run and everything is working. Then I try to click the button again without made any changes it will prompt the messagebox.
But when I made a changes in any document and change status to others such as "Active", and I go back to the form and click the button, it not prompting the message, but it skip the first If and proceed to else.
Below is my code:
If doc.PStatus(0) = "Lock" Then
Msgbox "Complete PC Inspection first!"
Exit Sub
Else
answer% = Messagebox("Do you confirm with this infomation?", 4,"Batch Number")
Some code...
...
End If
What I want to do is the button will not proceed to "else" if there still have "Lock" status in any document in the view. It will continue to "else" when there is no "Lock" status in the view. Any help will be appreciated. Thanks!
Better use a view that contains all Locked documents, ordered by the PC key or so. Or use a view sorted by key and Status, so you can pick out all locked documents for a specific PC. If there aren't any, GetDocumentByKey will return Nothing.

How to cancel all downloads in Chrome extensions and avoid displaying Save As dialog?

I'm trying to cancel every download just as they are started.
Here's my code so far:
var downloadCreated = function (a) {
// cancel the download
chrome.downloads.cancel(a.id);
chrome.downloads.erase({id: a.id}, function (d) {
});
};
chrome.downloads.onCreated.addListener(downloadCreated);
I've set Chrome to display Save As dialog when downloads are about to start.
I run my extension and click on a link several times. Sometimes the download is simply cancelled (which is the exact behavior that I want), and sometimes the Save As dialog is displayed. Clicking on Save button in the dialog has no effect and nothing will be downloaded. Whether the dialog is shown or not is random.
I'm just trying to avoid displaying the Save As dialog by any means.
Do you guys know a solution for this?
I found the solution some time ago but forgot to provide the answer. Here it is:
To stop a Chrome download attempt, chrome.downloads.cancel should be called in the proper event, that is chrome.downloads.onDeterminingFilename. That's it! No useless save dialogs will appear.

Click update after dialog appears Robotframework

I'm testing a scenario where I click on a button and below dialog appears. It's only possible to click on 'Update'
I have put following in my test scenario:
Click Element jquery=a.newOrder
Click Element Link=Update
I receive following error message after running the test:
Element is not clickable at point (1023, 127.19999694824219). Other element would receive the click:
The only HTML code that is related to the Update is
Update
I also try to test this with alert but no alert is found...
Can someone explain me what I need to do?
Thanks!
Explaining your scenario :
When you click update, a pop will be shown. You have to add a Wait until page contains element in any of the elements in pop up and then wait for the element you need to click. After the element is visible and focus is on the element. Click the element. If you get error in this, try to add selenium timeout for command execution speed or add a sleep to check whether the element loads slowly.

FB.ui - Send dialog reappears after submitting

We're seeing some strange behavior with Facebook Send dialogs (Javascript SDK, FB.ui method). After the Send button is clicked, the dialog disappears, then reappears. The dialog does disappear after a while without any user action, but this delay varies (anywhere from a split second to several seconds).
The messages are delivered without problems.
How to reproduce:
https://apps.facebook.com/barclays_pingit/
Click on "Send Message" under the "Tell a friend" title
Add a recipient and message
Click "Send"
Or:
Click on "Make your own video"
Choose a friend, how much they owe you, and for what
Click "Make video"
You can skip to the end of the video, then click "Send video to ..."
Add a message Click "Send"
Does anyone have any ideas?
Sorry I can't give you the answer, but as I have the same problem, here is a quick patch:
var callback = function callback(response) {
var clear_callback = function(){
$('.fb_dialog').remove();
};
var arr = [250,1000,2000,3000,4000,5000,7000];
for (var i in arr)
{
setTimeout(clear_callback,arr[i]);
}
}
FB.ui(obj, callback);

Resources