0
我正在使用Selenium Webdriver通過它自動化Salesforce應用程序。 測試場景: - 在賬戶頁面上,單擊「查找」(賬戶)搜索圖標打開標準Salesforce搜索彈出窗口。我無法切換窗口。Selenium Webdriver 3無法在標準Salesforce查找彈出窗口中識別對象
WebDriver popup=driver;
//Click on the Search icon of Account Lookup
element = driver.findElement(By.id("j_id0:formId:j_id29:j_id53:j_id54:3:j_id55_lkwgt"));
String Parent_Window = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
System.err.println("No of windows : " + handles.size());
element.click();
for (String s : handles){
String windowHandle = s;
popup = driver.switchTo().window(windowHandle);
System.out.println("Window Title : " + popup.getTitle());
System.out.println("Window Url : " + popup.getCurrentUrl());
if (popup.getTitle().contains("Salesforce")){
System.out.println("Selected Window Title : " + popup.getTitle());
driver = popup;
driver.switchTo().frame("searchFrame");
driver.findElement(By.id("lksrch")).sendKeys("Google");
driver.switchTo().frame("resultsFrame");
//Selecct account for search Account.
driver.findElement(By.xpath(".//*[@id='Account_body']//tr[2]/th")).click();
break;
}
}
driver.switchTo().window(Parent_Window);
return element;
你可以檢查是彈出一個iframe或使用xpath檢查標識 –
我已經確定它是iframe。 – Ajay
請使用switchtoFrame而不是switchtoWindow –