Strange issue with credit card authentication

122 views
Skip to first unread message

Shekhar Khandelwal

unread,
Feb 8, 2016, 12:24:52 AM2/8/16
to webdriver
I have developed a POM framework for a web application. Its a straight forward application with multiple pages with a payment page where we need to enter the credit card details. We have a dummy card details for testing. I manually enter those details and able to go through. But when I do the same through webdriver, the application is giving error stating that the details are incorrect.

Point to note is that if I reach till the payment page through webdriver execution, and then enter the credit card details, it wont work. I have to invoke the browser manually to get through.

Its happening with both IE and FF.

This is how I invoke the driver -

public static void setDriver() {

        // Choose the driver based on user browser selection
        switch (browser) {

        case ("ie"):

            System.setProperty("webdriver.ie.driver", execloc + File.separator + "IEDriverServer.exe");
            DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
            ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
            ieCapabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
       
            driver = new InternetExplorerDriver(ieCapabilities);

            break;

        case ("ff"):
           
              ProfilesIni profile = new ProfilesIni();
        FirefoxProfile myprofile = profile.getProfile("Selenium");
        driver = new FirefoxDriver(myprofile);
             
            //driver = new FirefoxDriver();
            break;
        }
    }



This is a very strange behavior. Kindly help me

Abhijeet Bedagkar

unread,
Feb 8, 2016, 5:08:05 AM2/8/16
to webd...@googlegroups.com, khandelwa...@gmail.com
Hi Shekhar

If I have understood your problem,correctly,

"There is a page with some text box controls and button called 'Confirm'  and upon the 'Confirm' button click the card values are verified.

When you do above operation manually it works and with automation with selenium it fails."

First of all this looks to me issue of text box event are not getting triggered when entered with selenium. hence can you check if there are any JavaScript events present around the textbox ? If yes then. after you add value to the text box can you try adding below line of code?

_remoteWebDriver.ExecuteScript("$(arguments[0]).change(); return true;", _remoteWebDriver.SafeFind("Locator"));

The above code will do the even trigger action. This is according to c# syntax.

Please let us know your findings.

Thanks,
Abhijeet
 


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

darrell grainger

unread,
Feb 8, 2016, 12:39:24 PM2/8/16
to webdriver
The fact you ran to a point using WebDriver than entered the credit card information manually was a good debugging step. That makes it very obvious that something is happening before you get to the credit card page. However, there isn't really enough here for me to discern what might be happening. 

The switch statement looks like your framework only supports IE and Firefox. Does it happen in Chrome? This is one possible avenue I would explore.

Another common error is mixing binaries from different versions of Selenium. If you get the IEDriverServer.exe for one version of Selenium but the client bindings (JAR files) for another version of Selenium, it can have unexpected results.

You also note that it fails in both IE and Firefox. But does it fail for the same reason? I know that the released binaries for Selenium are usually one release behind the current Firefox. So if you system automatically updates to the latest version of Firefox, the latest released version of Selenium might not work with it. This means IE might be failing because of the wrong version if IEDriverServer.exe and Firefox is failing because you have the latest version of Firefox.

The final reason which pops to mind is that your framework is doing something which causes the browsers to launch in a state which causes the application to fail. This is the first thing I would check. I'd write a quick and dirty Selenium script which opened the browser, when to the test page then waited. I'd set a breakpoint on the wait, run to breakpoint then try entering the credit card number manually. If that works then I'm pretty sure the problem is in the way your framework is launching the browsers.

Additionally, I would look at the browser console (F12 on IE) and see if there are any javascript errors that might give me insight into why it is failing. Is the failure a message from client side javascript? Or is it making a call to a backend service? If it is making a call to a backend service, is there anything in the service logs which gives insight?

The simplest of scripts to open a browser would be:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class Main {
public static void main(String args[]) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
String url = "http://www.google.com";
driver.get(url);
driver.quit();
}
}

Set a breakpoint on the driver.quit() call. Change the www.google.com to the URL for your application. Debug to the breakpoint. Use the browser to get to the credit card page and try entering a valid credit card number (if it is using the generic Luhn check you can use 8888 8888 8888 8888).
Reply all
Reply to author
Forward
0 new messages