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,320 points
7,302 views
I am also having same problem i wanna eneter card details but that card box only accept Interger
Have you managed your problem?
I tried @Samrapit's solution and it pretty much worked for me!

1 answer to this question.

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,910 points

Related Questions In Selenium

0 votes
3 answers

What are the different ways to select an option from a dropdown using Selenium Webdriver?

So follow this steps for solution: First click ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
52,217 views
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 28, 2018 in Selenium by Meci Matt
• 9,460 points
6,191 views
0 votes
2 answers

How to get the text from a website using selenium?

driver.findElement(By.cssSelector("p")).getText() or  IWebElement element = Browser.GetElementByCssSelector("div.loginbox p"); string text = ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
25,745 views
0 votes
1 answer

How to extract text from a web page using selenium and save it as a text file?

Hello Isha, you can checkout this code ...READ MORE

answered May 7, 2019 in Selenium by Anvi
• 14,150 points
33,767 views
0 votes
2 answers

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,500 points
13,776 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,190 views
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,910 points
7,267 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,904 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,910 points
2,786 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP