How to automate a website login in such a way that we should know each step whether its is executing or not in java…?

huangapple 未分类评论44阅读模式
英文:

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']")

huangapple
  • 本文由 发表于 2020年4月4日 12:46:41
  • 转载请务必保留本文链接:https://java.coder-hub.com/61023877.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定