Test razorpay payment flow using cypress - ruby-on-rails-3

I am trying to use cypress for testing my Razorpay payment flow in my ROR project.I am able to get fields in iframe,select a bank and click on "Pay rs 399 now".On clicking the "Pay now button" a new window opens up which has two options to make the payment success OR fail it.Everything till now is already tested in cypress...My question is how do I access the new window opened using cypress and click "success"
I HAVE TRIED:
As I was not able to access the new window.I tried adding a random razorpay_payment_id and amount and passing it directly using "POST" request to my "update" action in the Subscription Controller.But alas!!! this action chks if razorpay_payment_id is present and if present fetches it like
payment = Razorpay::Payment.fetch(params[:razorpay_payment_id]).
capture({ amount: params[:amount] })
which errs to "The id provided does not exist"
Also tried:
refered this question to access the new window...But got an err "Expected "open" to be called at least once.But was never called"
Please help!!
here are the images for ref
(1)this image shows the razorpay modal before i finally click on pay button
(2)here is the new window which opens when I click PAY.

Related

Intercepting a HTTP request in the middle of a test in Testcafe

I am writing a functional test using Testcafe. The test scenario is as below,
There is a toggle button that activates/deactivates based on an API call
When I open my application, an API call is made that returns a value ON/OFF; based on that, the toggle switch is activated or deactivated.
I want to intercept that call when the user clicks on that toggle button again.
Long story short:
User logs in
XYZ API is called made, and it gives the response ON
Based on that response, the toggle button is activated
Then user will click on the toggle button
Now the XYZ API should be called again which will return OFF
await t.navigateTo(`${url}`);
await t
.click(myPage.toggleSwitch)
.addRequestHooks(myPage.xyzAPI.respond([{ valueBar: "ON" }
]))
.expect(myPage.toggleSwitch.checked)
.eql(true);
});```
I want to intercept that call when the user clicks on that toggle button again.
You need to add the target request hook before the click action. Also, before the click action, the actions chain should be broken.
await t.navigateTo(`${url}`);
await t.addRequestHooks(<hook that caught the API calls>);
await t
.click(myPage.toggleSwitch)
.expect(myPage.toggleSwitch.checked).eql(true);

How to get response back from Chrome Custom Tabs in react-native

I want to get response from URL that is opened into chrome custom tab. actually i have some forms in external url that is submitted and return data array on success page. I want to get array into my app. when user click on button custom tab will open and submit required fields and goes into success page. I want to do custom tab will be close automatically and fetch array into app and want to create success page into app.

How to handle popup window using selenium webdriver with Java

Please help, I'm new in Selenium. I try to automate eCommerce website and I have problem to handle popup window. Here is the scenario:
Go to http://www.lampsplus.com
Click on Sale link in the header section.
Click on the 1st item/product displayed on the page. (This will show the product page).
On the product page, click on the red Add To Cart button. (This will add a product to cart and display a popup).
On the popup, click the dark-grey Continue Shopping button. (This will close the popup.)
I stuck on step 5 (Error message: Unable to locate element "Continue shopping button")
Here is my code before step 5:
WebDriver d1 = new FirefoxDriver();
d1.manage().window().maximize();
d1.get("http://www.lampsplus.com");
d1.findElement(By.name("hdr_sale")).click();
d1.findElement(By.xpath(".//*[#id='sortResultContainer60238']/a[2]/span")).click();
d1.findElement(By.id("pdAddToCart")).click(); //This is step 4
//Here is suppose to be some code which handles the popup - my problem
d1.findElement(By.id("aContinueShopping")).click(); //This is step 5
I'm aware about .getWindowHandle(); method. I tried several variations of it and none of them worked.
Can anyone give me an idea how to handle it. Many thanks! I use Java.
Note: I don't work for LampsPlus and not try to promote their products, this website was chosen for training purposes only.
The element aContinueShopping is contained within an iframe.
You'll have to switch to the iframe using:
WebElement frameID = d1.findElement(By.Css("#add-to-cart>iframe"));
d1.SwitchTo().Frame(frameID);
d1.findElement(By.id("aContinueShopping")).click();
There's no 'name' or 'id' on the iframe, so you'll have to use a WebElement or a numeric to find it.
Once you're done with that iframe, you'll switch back to 'top' by using:
d1.SwitchTo().DefaultContent();

Handling the google interactive post onclick via javascript

My scenario is as follows:
Our application is building on top of google-plus and takes advantage of the google-plus connections.
Is this supported with Interactive posts? I want to:
Block showing the interactive post dialog on the button click if a certain condition is not met
Perform a certain action once the button to show the dialog is clicked - onClick works for this but I could not find documentation on it.
var options = {
contenturl: url,
clientid: googleappid,
cookiepolicy: "single_host_origin",
prefilltext: text,
calltoactionlabel: "START",
calltoactionurl: ctaurl,
recipients: connectionid,
onClick: specialFunctionToRunOnClick(params)
};
gapi.interactivepost.render('submitInvitationongoogle', options);
Is there something like beforeSend that can prevent the click from firing?
There currently is not an API for testing whether the user has created an interactive post on their stream. You can know when the interactive post was rendered to the user by logging the API calls for gapi.interactivepost.render and can use the call-to-action url for testing when the recipient clicked the button. You can also look at their public stream activity to test whether the post was shared publicly but this is probably not what you want.

API Error Code 102 : javascript dialogs with php

API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key
I get this funny message when calling a fb dialog to post to a friends wall in my new app. The same code is working for other apps. This suddenly stopped working. When i specifically dont set iframe, a weird pop up now pops up now. As browsers block pop ups it doesnt turn up.
Also auto posting directly is not working even when user permits. My app is not unresricted also. Any one has any idea ??
I've had this error, when calling dialog without user interaction. For example when both 'document ready' and 'FB js-sdk loaded events' are fired. When i called the dialog with same function, parameters, on same page but in reaction on user mouse click - it worked.
If this is similiar to what you have, here is the solution:
FB.getLoginStatus(function(response) {
if (response.authResponse) {
//call dialog here
}
});