Is there a way to read Chrome browser alerts in Selenium Webdriver? - python-3.x

Currently developing a checkout script and on the final stage a Chrome alert appears within the Webdriver like here: https://i.stack.imgur.com/tPyT4.png
I need to be able to read what that message says to determine if the payment was successful, if so I need to be able to terminate all other instances of script I plan to run from a batch file, and print that payment was successful. Or if payment decline or gateway is rejected as shown above, I need to be able to print that it was declined or that there was a gateway rejection.
Thank you:)

Have you try
driver.switchTo().alert()
One you have switched, something like
driver.getPageSource() should work

Related

Stripe API testing automation

Background
I am integrating stripe API into my site to take one off payments. My site will be API first on server side with a separate web and mobile front end. I am working on the API server side code. I will eventually use stripe payment pages to take credit card payments. I am trying to automate the testing of my APIs and am bamboozled by the documentation (which are thorough) as I just can't see what steps to take next.
My server side initiates a call with stripe using stripe sdk to create a stripe Session object - this contains a URL to redirect to checkout.stripe.com/pay/..., a success URL when payment is successful and a cancel URL (these I set to handle the callback).
Problem
I can automate in Postman all my API calls from Browse Products, Select Product, Place Order but the next step I am stuck. After Placing Order I get back the stripe session but how can I mimick making the payment with stripe for the session and then call my Success URL ?
When the site is complete I will redirect the UI to stripe to take payments but I am testing and completing the back end flow first.
I have copied and pasted the session URL which is returned by the stripe Session object to bring up the page in a browser and used Dev tools on Chrome to inspect Network to see which APIs are being called by stripe in an attempt to reproduce and I can see a POST to stripe.com/api/payment_methods and I can see the posted values but I can't reproduce this in Postman. Also, the documentation (https://stripe.com/docs/api/payment_methods/create) says
"Instead of creating a PaymentMethod directly, we recommend using the
PaymentsIntents API to accept a payment immediately"
Question
Which stripe APIs do I need to call to automate the flow from a stripe Session object to make a payment and then check that it was successful? Payment Methods? Make a Charge? Payments Intents? ...and how. Happy to be pointed to the documentation if you can help me understand the flow.
TIA
Checkout is a Stripe product that looks like a "box" and you can't know (and shouldn't need to know) what happens inside. It is created for the purpose that merchants won't have to think about what's being done under the hood.
Speaking from an automation perspective, you can try to reproduce the whole process but there's no guarantee it won't change in the future, and it could leave you with more problems later.
For options to reproduce:
The closest way is simulating browser filling and submission, using automated browser tools (ie Selenium). But it's not as straightforward as PostMan. Generally you would want to simulate every browser action that a human could do.
Or you can try to accomplish the same with the logs and events you receive on Stripe's Dashboard, when you test a Checkout Session by yourself. From now there are 3 requests.
And your goal is to receive the same 5 events in Webhook:
TBH I recommend to reconsider the need of this test, to see if it worth your efforts.

Stripe Does Not Attempt to Contact My Webhook

I am building my first Stripe integration with a Wordpress plugin and cannot get Stripe to attempt to contact my webhook. I have followed the instructions at https://stripe.com/docs/checkout/integration-builder and successfully made some test payments. Then I copied and pasted the sample code at https://stripe.com/docs/payments/checkout/fulfill-orders into a file named webhook.php and configured the CLI stripe listen setting with that URL except instead of localhost mine starts with 127.0.0.1. Then I pasted the webhook authentication code into the webhook.php file and made another test payment. It worked fine, but there was no attempt to access the webhook.
What am I missing, is there something I need to add to the sample app from the first URL I listed to instruct the checkout process to ping my server? The sample app does not include a webhook and the page with the fulfillment instructions has no link to any sample app, so I can't tell if I need to add anything more to my create-checkout-session.php file. The Stripe instructions are not very good.
There is also no way to type anything into cmd.exe after it gives me my webhook signing secret. It just has a blinking _ character underneath the line with the secret and anything I try to type anything nothing appears on the screen.
I checked my account on the Stripe website and under the checkout.session.completed event it says "No recent webhook attempts"
My problem was that there are two types of webhook listeners. One is called Direct en the other Connect.
When you create a webhook you can select the box: Listen to events on Connected accounts. Tick it and you create a Connect listener. Don't tick and it's a Direct one.
In my case a charge.succeeded was only listened to in the Direct version of the listener.
Exactly why eludes me. But the support said:
"The first webhook [the Connected type] that you create will inform you regarding the connected accounts."
"And the second one [the Direct type] from your platform"
It sounds like Stripe CLI may not have been running properly; are you following the instructions here? https://stripe.com/docs/stripe-cli/webhooks

Facing issue in Load Runner

I am new to load runner tool.I have to perform load testing for payment gateways. When I record the script using HP Load Runner the script is recorded successfully. When i replay the same script to check whether script is passed or not. Then, script does not show any error.So,i started giving load on the same script then for the payment the entry which i am getting in transaction list in "Awaiting" and when i do manually payment the entry i get is "Completed".So, according to the "Awaiting" status payment is not done successfully.
I am new to load runner tool.
Have you had training in the tool?
Have you been provided a mentor for a period of time until you are proficient with the tool?
Has your management refused you access to either of the two previous items?

Gmail push notification error (Only one user push notification client allowed per developer)

I tried to execute gmail api's watch on my two gmail accounts and it works fine.
But when the other user tried to do so, it shows this error:
HTTP error 400 : "Only one user push notification client allowed per developer (call /stop then try again)">
I don't know if the problem is on the pub/sub client configuration or doing stop and watch will resolve the problem?
Can someone explain the meaning of this statement "Only one user push notification client allowed per developer"?
Try using a different project for the Cloud Pub/Sub topic that the other user wants to set up a Gmail API watch on.
You can always renew a watch by first stopping the watch and then immediately initiating a new watch right after. So, try to use users.stop once before you use users.watch.
I have encountered a similar issue. Although this might not be helpful to the OP, for me the solution was to abandon Google's Pub/Sub and use IMAP IDLE instead, which is much better suited for OP's use case of monitoring several inboxes.

apps script not found error

I had the snooze app script working on gmail for some time but it seems that after converting to google drive, the spreadsheet vanished (not in trash) and I get emails every night telling me that my script "Not Found" failed to finish successfully etc etc.
The Error message is that a server error occurred - not particularly informative and any attempt to view triggers results in the same error.
Is there any way to get rid of these messages apart from setting up some kind of filter which is counter intuitive as if I decide to run other scripts I may want to see the output.
Thanks
Darren
Darren, can you please raise this on the Apps Script issue tracker: http://code.google.com/p/google-apps-script-issues/issues/list? If possible, please also let us know in the issue tracker request what the email address is where you're receiving the failure notification email.

Resources