Sending keys to credit card fields (fields are from stripe) using selenium

0 votes

For the below cases:I tried automating few the test cases for payments. Which is integrated with Stripe.

driver.findElement(By.id("cardNumber")).sendKeys("4242424242424242");

driver.findElement(By.id("cardNumber")).sendKeys(Keys.NUMPAD4);// send keys one by one

Looks like selenium is sending the keys as a string and the card fields allow only integers.

Jun 12, 2018 in Selenium by Martin
• 4,210 points
475 views
I am also having same problem i wanna eneter card details but that card box only accept Interger

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Below code will help you:

String cnum = "4242424242424242"

Use a for loop to extract single character and use second pointer in your question, as below:

for (char ch : cnum.toCharArray()) {

    switch (Integer.parseInt(String.valueOf(ch))) {

        case 1:

            driver.findElement(By.id("cardNumber")).sendKeys(Keys.NUMPAD1);

            break;

        case 2:

            //and so on...

    }

}
answered Jun 12, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

Is it possible for a website to detect that we are using Selenium with ChromeDriver

Selenium tests for pre-defined javascript variables which ...READ MORE

answered Apr 27, 2018 in Selenium by Meci Matt
• 9,400 points
1,698 views
0 votes
1 answer

How to get the text from a website using selenium?

hey, you can use get.text() method to ...READ MORE

answered Dec 31, 2018 in Selenium by Sudhanshu
66 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
77 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
449 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
57 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
159 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.