Can not click on next button before payment page | Selenium Forum
M
Posted on 28/12/2016
i m trying to automate payment gateway
stripe checkout
i am able to print the text on the stripe checkout overlay
howver i am not able to click on the fields on their check out page
since the xpath keeps changing each time
also the css locator keeps changing
for each transaction
Code attached in text file



package testcases;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Stripe_checkout {
public static WebDriver driver;
public static String vURL,emailID,pswd,cart_time,myusername;

public static void main(String[] args) throws Exception {
System.setProperty("webdriver.gecko.driver",System.getProperty("user.dir")+"\\src\\test\\resources\\browsers_exes\\geckodriver.exe");
driver = new FirefoxDriver();
emailID= "swapnali.kulkarni@yapsody.com";
pswd="Account123";
vURL = "https://million.yapsody.com/";
driver.get(vURL);
Thread.sleep(5000);
driver.findElement(By.xpath(".//*[@id='login-name']")).click();
driver.findElement(By.xpath("//*[@id='email_address']")).sendKeys(emailID);
driver.findElement(By.xpath("//*[@id='password']")).sendKeys(pswd); // Login completed
driver.findElement(By.xpath("//*[@id='user_login']/button")).click();//more info button click
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='event_55610']/div[2]/div[2]/div/p[3]/a")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='0']/span/a")).click();//get tickets button click
Thread.sleep(2000);

driver.findElement(By.xpath("//*[@id='continue_shopping']/a[1]")).click();// Next step after seat selection
Thread.sleep(2000);

driver.findElement(By.xpath("//*[@id='store-body']/div/div[3]/div/a")).click();//attendee details next stepbutton
Thread.sleep(4000);
driver.findElement(By.xpath("//*[@id='store-body']/div/div[3]/div/a")).click();// Select Ticket delivery - Next Step button
Thread.sleep(2000);
cart_time=driver.findElement(By.xpath("//*[@id='cart_timer']")).getText();
System.out.println(cart_time);
Thread.sleep(2000);
((JavascriptExecutor)driver).executeScript("scroll(0,400)"); // scrolling using javascript.

Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='store-body']/div/div[3]/div/a[1]")).click();// review cart checkout button click

Thread.sleep(8000);
driver.findElement(By.xpath("//*[@id='payment-methods']/li/a/span[2]")).click();// payment method credit card selection.

Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='paymentForm']/div[5]/label")).click();

Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='paymentForm']/div[7]/button")).click();//submit button for stripe checkout

Thread.sleep(3000);
driver.switchTo().frame("stripe_checkout_app");
myusername = driver.findElement(By.xpath(".//*[@id='container']/section/span[2]/div/div/main/div/header/div[2]/div/div/span")).getText();
System.out.println(myusername);

Thread.sleep(8000);
driver.findElement(By.xpath("//*[@id='90e725b0-ccc5-11e6-85b9-0bfd7aac0b7e']")).sendKeys("Darren Seiden");
}

}

M
Replied on 28/12/2016

use placeholder xpaths. try these.

//*[@placeholder="Name"]
//*[@placeholder="Street"]
//*[@placeholder="City"]
//*[@placeholder="Postcode"]