Webdriver (Java) - проблема печати [ChromeDriver: chrome на XP] - PullRequest
0 голосов
/ 18 мая 2018

Я использую следующие версии:

  • TestNG 6.11.0
  • ChromeDriver 2.38.552522
  • Windows 7

Мой скрипт печатает путь findelement целого числа значений, относящихся к связанному element. Не уверен, что пути, определенные в findelement, являются основной причиной или новой версией ChromeDriver. После запуска тестового скрипта я получаю в консоли следующее:

[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/div[2]/div[1]/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> class name: ng-star-inserted]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> class name: card-price]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> class name: card-subtitle]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> class name: explore-mi]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[1]/div[1]/h4]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[1]/div[2]/h4]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[1]/div/div[1]/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[1]/div/div[2]/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[2]/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[2]/div/div[1]/div/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[2]/div/div[2]/div/p]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[3]/div/div[1]/div[1]/h4]
[[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[3]/div/div[1]/div[2]/p]

Мой скрипт, как указано ниже:

`

@Test(priority = 13)

public void Explore_check_input_in_feedback () throws InterruptedException

{

WebElement CampaignName = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[1]/div[1]/h4"));

WebElement NowPay = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[1]/div[2]/h4"));

WebElement StartDate = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[1]/div/div[1]/p"));

WebElement EndDate = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[1]/div/div[2]/p"));

WebElement Estimations = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[1]/div[2]/p"));

WebElement Budget = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[2]/div/div[1]/div/p"));

WebElement BusinessOutcome = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[2]/div/div[2]/div/p"));

WebElement TotalCost = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[3]/div/div[1]/div[1]/h4"))    WebElement Savings = driver.findElement(By.xpath("html/body/max-app-root/max-explore/max-campaign-information/div/aside/div[2]/div[3]/div/div[1]/div[2]/p"));

    CampaignName.getSize();
    Assert.assertTrue(CampaignName != null);
    System.out.println(CampaignName);

    NowPay.getSize();
    Assert.assertTrue(NowPay != null);
    System.out.println(NowPay);

    StartDate.getSize();
    Assert.assertTrue(StartDate != null);
    System.out.println(StartDate);

    EndDate.getSize();
    Assert.assertTrue(EndDate != null);
    System.out.println(EndDate);

    Estimations.getSize();
    Assert.assertTrue(Estimations != null);
    System.out.println(Estimations);

    Budget.getSize();
    Assert.assertTrue(Budget != null);
    System.out.println(Budget);

    BusinessOutcome.getSize();
    Assert.assertTrue(BusinessOutcome != null);
    System.out.println(BusinessOutcome);

    TotalCost.getSize();
    Assert.assertTrue(TotalCost != null);
    System.out.println(TotalCost);

    Savings.getSize();
    Assert.assertTrue(Savings != null);
    System.out.println(Savings);
    }`

1 Ответ

0 голосов
/ 18 мая 2018

Поскольку я обновил ChromeDriver, для печати я должен четко определить его.Пример;Если в сценарии определен WebElement Error и я напишу System.out.println(Error), он напечатает path элемента.Я должен упомянуть System.out.println(Error).getText() вместо того, чтобы напечатать фактическое значение.

...