• Post Reply Bookmark Topic Watch Topic
  • New Topic

Selenium: Getting error in payment page  RSS feed

 
Monika Jha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on an automation suite for payment page, after entering Credit card number, Image attached
we have 2 buttons which should enable
1- Check credit card
2- CVV

But after entering Credit card number, it is not enabling. Please help,
PSB code.

package page.object.classes;

import static org.testng.Assert.assertTrue;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;

import commons.WaitTypes;
public class PaymentInfoPage {
                WebDriver driver;
               
                @FindBy(xpath=".//h1[contains(.,'Payment Information')]")
                WebElement paymentInfoText;
               
                @FindBy(id="cardHolder-first-name")
                WebElement cardHolderName;
               
                @FindBy(id="card-Number")
                WebElement cardNumber;
               
                @FindBy(id="btnValidateCardNumber")
                WebElement btnValidateCardNumber;
               
                @FindBy(id="cvv")
                WebElement cvv;
               
                @FindBy(xpath=".//*[@id='expirationMonth_chzn']/a/span")
                WebElement monthDropDown;
               
                @FindBy(xpath=".//*[@id='expirationMonth_chzn_o_3']")
                WebElement monthDropDownSelection;
               
                @FindBy(xpath=".//*[@id='expirationYear_chzn']/a/span")
                WebElement yearDropDown;
               
                @FindBy(xpath=".//*[@id='expirationYear_chzn_o_3']")
                WebElement yearDropDownSelection;

                @FindBy(xpath=".//*[@id='checkTermsAndConditions']//span")
                WebElement termsCheckBox;

                @FindBy(xpath=".//*[@id='creditCardDetailsSection']/div")
                WebElement dummyClick;

                @FindBy(xpath=".//*[@id='btnValidatePayment']")
                WebElement btnValidatePayment;
               
               
               
                public PaymentInfoPage(WebDriver driver){
                                this.driver = driver;
                                                PageFactory.initElements(driver, this);
                }// End of Class Constructor

                public void paymentProcessing(String ccName, String ccNumber, String cvvNumber)  {
                                WaitTypes.getWhenVisible(driver, cardHolderName, 40).clear();
                                cardHolderName.sendKeys(ccName);
                                WaitTypes.getWhenVisible(driver, cardNumber, 10).clear();
                                cardNumber.sendKeys(ccNumber);
                               
                                cardNumber.sendKeys(Keys.chord(ccNumber));
                               
                                //JavascriptExecutor jse = (JavascriptExecutor) driver;
                                //jse.executeScript("document.getElementById('card-Number').focus();");
                               
                               
                                //cardNumber.sendKeys(Keys.ARROW_DOWN);
                               
                                //new Actions(driver).moveToElement(driver.findElement(By.id("card-Number"))).click().sendKeys("Test").build().perform();

                                dummyClick.click();
                                cardNumber.sendKeys(Keys.ENTER);
                                Assert.assertTrue(btnValidateCardNumber.isEnabled());
                                WaitTypes.getWhenVisible(driver, btnValidateCardNumber, 50).click();
                                btnValidateCardNumber.click();
                                //WaitTypes.waitUntilJQuery(driver, 10);            
                                WaitTypes.getWhenVisible(driver, cvv, 50).sendKeys(cvvNumber);
                                WaitTypes.clickWhenVisible(driver, monthDropDown, 20);
                                // WaitTypes.clickWhenVisible(driver, monthDropDown, 40);
                                // WaitTypes.clickWhenVisible(driver, monthDropDownSelection, 10);
                                WaitTypes.clickWhenVisible(driver, yearDropDown, 10);
                                WaitTypes.clickWhenVisible(driver, yearDropDownSelection, 10);
                                WaitTypes.clickWhenVisible(driver, termsCheckBox, 10);
                                // btnValidatePayment.click();
                                JavascriptExecutor js = (JavascriptExecutor) driver;
                                js.executeScript("window.scrollBy(0,250)", "");
                                /*WaitTypes.clickWhenVisible(driver, btnValidatePayment, 250);*/
                                try {
                                                Thread.sleep(3000);
                                } catch (InterruptedException e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                }
                                WaitTypes.clickWhenVisible(driver, btnValidatePayment, 10);
                                //js.executeScript("arguments[0].click();", btnValidatePayment);
}
               
               
                public boolean verifyPage(){
                                try {
                                      assertTrue(WaitTypes.getWhenVisible(driver, paymentInfoText, 55).getText().contains("Payment Information"));
                                      return true;
                                    } catch (Exception e) {
                                                return false;
                                    }
                               
                }//End of
[/i]VerifyPage method

}
pp.png
[Thumbnail for pp.png]
payment page issue
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!