Webdriver(Java)-[ChromeDriver:chrome on XP]打印问题
我正在使用以下版本:Webdriver(Java)-[ChromeDriver:chrome on XP]打印问题,java,selenium,selenium-webdriver,webdriver,selenium-chromedriver,Java,Selenium,Selenium Webdriver,Webdriver,Selenium Chromedriver,我正在使用以下版本: TestNG 6.11.0 ChromeDriver 2.38.552522 视窗7 我的脚本打印属于相关元素的findelementintead值的路径。不确定findelement中定义的路径是根本原因还是新版本的ChromeDriver。在运行测试脚本时,我在控制台中看到以下内容: [[ChromeDriver: chrome on XP (8d6e0228a90daac67d21f6c2ff1c0ef3)] -> xpath: html/body/max-
- TestNG 6.11.0
- ChromeDriver 2.38.552522
- 视窗7
元素的findelement
intead值的路径。不确定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]
我的脚本如下所述:
`
因为我更新了ChromeDriver
,所以为了打印,我必须清楚地定义它。
实例如果脚本中定义了WebElementError
,并且我写入了System.out.println(Error)
,它将打印元素的路径。我必须提到System.out.println(Error.getText()
来打印实际值 同时显示你的脚本代码。这是一个庞大的代码,只是复制了其中的一部分,这就产生了问题。请把问题再提一遍。我已经更新了。
@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);
}`