Is there a way to intercept an event in vue and continue it later? - vue.js

I want to achieve something that I have seen multiple times on various sites. I'll provide a scenario so it will be easier to understand what I'm trying to achieve. Let's say I have a button which executes file downloading. Sometimes this button might have additional event to open up a modal with some information, after clicking "continue" in this modal, the download event should be fired as if it would without this interception. There might also be a cancel button in that modal which would cancel the download action. How might I achieve this? I already had this implemented using jquery but now I'm reworking my project to use vue and the way I achieved it with jquery was very dirty, hack-ish and unstable.

Related

Selenium element.click() does not work

Hello: I am using Selenium/Java to grab a PDF from a website. The website does not generate them in advance, but only after I clink on a link. When I do, the web server goes away for a few minutes, and then comes back with the content.
I'm using Firefox, and its built-in PDF viewer. When I click on the download link from the main browser window, it opens another window to receive the PDF content. In a few minutes the child window is filled with the PDF content, and all I need to do is click a download button on the Firefox toolbar, and then press a Save button on the confimration dialog. I have done both of these things, successfully, sometimes.
My problem, sometimes occurs when I execute the code to click on the child window's download button...
WebElement element = driver.findElement(By.id("download"));
element.click();
Sometimes, it just doesn't work. The statement:
driver.findElement(By.id("download"))
...never throws an exception, so it appears to always be successful. Yet, the subsequent element.click() will often not produce the expected results.
I've thrown about 100 darts at this problem, but I can't seem to find one that produces consistent results. I've tried introducing delays, calling findElement several times, trying to use the driver on the child window in ways to confirm its connection to that window (all with positive return values), but nothing seems to help make element.click() on the darn download link successfull.
I have found Selenium to be a rock-solid solution, especially when working through the primary window...it never misses a beat, and I'm really quite impressed about that behavior. This is my first Selenium project, and I hoping someone that has used it a bit more, might have a suggestion for this particular problem.
It's hard to answer this question without additional information about how the child window is populated. If the child window is using javascript to add the button to the page and define its behavior (which is likely), then the element could be actually present on the page when you look for it (i.e. no error will be thrown), but it might not be active yet or prepared to be clicked.
It might be a good idea to look at the element definition in the source for the child page to get a better idea of how the button is coded. If you have access to the web developers who designed/implemented the button even better. If you can wait to perform the click action until the button is in the desired state, this should solve the problem.
Additionally if the page is coded using a dynamic framework like Angular, you might be better off using Protractor for testing, which is based off of Selenium, but which is aware of updates in the view as they are occurring.

PhantomJS click action not working on span when trying to login to Office365

I am trying to automate office365 operation, and try to login using phantomjs. I use sendEvent to send click to the span UI item (which happens to be the fake submit button). I use render to capture the screen-shot after sending the click event, and it seems the button is selected (greyed out) but never receives the click event.
I have a similar problem when trying to "click" this button with Selenium.
Has anyone ever successfully automated the office365 login? I guess this has something to do with the way the web page is structured. (There is another layer of javascript that receives the click event then redirect the user to the app page).
Is there any other tool that is better fit for such task? (I tried twill as well, and have no luck.)
I have a Selenium project that logs into Office365, but I've also had a lot of issues with being able to do it consistently. The CSS selector I'm using for the Sign In button is #cred_sign_in_button. If you look at the source, that is a span that has the click handler.
<span id="cred_sign_in_button" tabindex="11" **onclick="Post.SubmitCreds()**;return false;" class="button normaltext cred_sign_in_button refresh_domain_state" role="button" style="opacity: 1;">Sign in</span>
I've found that clicking on the button once doesn't work most of the time. I assume that's due to the animation happens when you hover over the button. What finally ended up working for me was to click, wait 250ms and click again.

Does Magnific Popup support custom events/buttons

I know Magnific Popup supports certain events such as Close, Next, etc. out of the box. But does Magnific support custom buttons and events if I wanted to add my own event hooks, such as Download, email, buy, or whatever button I wanted to created. I'm really just looking to be able to create my custom menu within the image 'div' area or directly beneath it. An example somewhere would be great. I just haven't been able to find any.
Before starting I would recommend reading the Magnific Popup Documentation
and familiarizing yourself with the available examples, more specifically the Pin it button example.
Naturally, you will have to code out the functionality of your menu items as you need them.
For the how to's on the specifics of your buttons you will have to do more specific searching as it does not appear that there is a built in
magic(click, poof)
{
//amazing things happen
}
function.
Good luck!

how to click on WebArea from QTP ?

In My test I want to click on object of Type WebArea which opens a webelement popup includes some fields that i need to test.
the problem that the popup not open after I click on WebArea object through the code.
the code I use as below.
Browser("WW").page("assessment").WebArea("areaassessment").Click
nothing hapens after the above line excuted.
Look into the HTML of the WebArea and see what action is triggering the popup. Normally it has something like onclick='showPopup();', but in other cases it is onmousedown or onmouseup.
If this is the case, you have to setup QTP accordingly. There are multiple roads to walk here, one is to see how you advanced web settings are configured. Go to Tools>Options>Web>Advanced and look in the Run Settings.
Setting the Replay Type to Event will replay your scripts by events (by default mousedown, mouseup and then mouseclick) or by mouse (You'll see your mouse pointer moving in this mode, QTP will replay by sending WM_* messages through the Windows api for movement to the correct screenlocation and triggering the click).
Allthough it replays a bit faster, if Run only click is checked, it is better to uncheck this to trigger all events / messages.
Events can also be fired by the FireEvent method:
Browser("WW").page("assessment").WebArea("areaassessment").FireEvent("onclick")
or through the object native methods:
call Browser("WW").page("assessment").WebArea("areaassessment").Object.click()
call Browser("WW").page("assessment").WebArea("areaassessment").Object.FireEvent("onclick")
As #AutomateChaos said there is probably an event that QTP isn't simulating, one way to work around this is to do as #AutomateChaos suggests and simulate the needed event. A simpler way is to change to device replay (as I described here and here).

Testing checkbox click

I have started testing my UI using qUnit, so I need to simulate some user interaction. Is it possible to "simulate" a user clicking a checkbox using javascript ?
Thx guyes. I figured it out about two seconds after I posted the question. It was as you say simpler than I had imagined
document.getElementById('cb1').click();
did the trick
Edit: It seems in IE7 (and perhaps other browsers) the the click method will not actually check the checkbox. So to fully simulate you need to "check" the checkbox before clicking it
document.getElementById('cb1').checked=true
document.getElementById('cb1').click();
You can look at this:
Simulate a buttonclick via javascript
It is the other way arround, so i'm not sure if it works on checkboxes too.