英文:
How to automate a website login in such a way that we should know each step whether its is executing or not in java...?
问题
String URL = JsonPath.read(resp, "$..data.amazonPayResponse.amazonPayLoad.paymentRedirectUrl").toString().replaceAll("[\\[\\]\"]", "").replaceAll("\\\\/", "/");
System.out.print("\n=============link==========\n" + URL);
WebDriver driver = new HtmlUnitDriver();
driver.get(URL);
driver.findElement(By.id("ap_email")).sendKeys("1234xxx123");
driver.findElement(By.id("ap_password")).sendKeys("xxxpasswordxxx");
driver.findElement(By.id("signInSubmit")).click();
WebDriverWait wait = new WebDriverWait(driver, 60);
WebElement payNowBtn = wait.until(ExpectedConditions.elementToBeClickable((By.xpath("/html/body/div[1]/div[1]/div[3]/div/div/div[2]/div/div/div/div[2]/div[2]/form/div[2]/div[1]/div[1]/div/span/span/input"))));
payNowBtn.click();
driver.quit();
英文:
I need to automate the 3 click step first login and next page is the pay button, in code i am not getting any error but i am not able to verify that, whether it is executing every step or not, where it is failing, which click is missed out.
Here is my code please review it.
String URL = JsonPath.read(resp, "$..data.amazonPayResponse.amazonPayLoad.paymentRedirectUrl").toString().replaceAll("[\\[\\]\"]", "").replaceAll("\\\\/", "/");
System.out.print("\n=============link==========\n"+URL);
WebDriver driver = new HtmlUnitDriver();
driver.get(URL);
driver.findElement(By.id("ap_email")).sendKeys("1234xxx123");
driver.findElement(By.id("ap_password")).sendKeys("xxxpasswordxxx");
driver.findElement(By.id("signInSubmit")).click();
WebDriverWait wait = new WebDriverWait(driver, 60);
WebElement payNowBtn = wait.until(ExpectedConditions.elementToBeClickable((By.xpath("/html/body/div[1]/div[1]/div[3]/div/div/div[2]/div/div/div/div[2]/div[2]/form/div[2]/div[1]/div[1]/div/span/span/input"))));
payNowBtn.click();
driver.quit();
答案1
得分: 0
这个路径在我使用时是有效的,但仅在本地机器上运行,而不在Jenkins中运行。
By.xpath("//input[@name='ppw-widgetEvent:SetPaymentPlanSelectContinueEvent']")
英文:
It is working when I use this path but still it only works in local machine not under Jenkins
By.xpath("//input[@name='ppw-widgetEvent:SetPaymentPlanSelectContinueEvent']")
专注分享java语言的经验与见解,让所有开发者获益!
评论