我試圖自動化naukri.com應用程序,並且當我啓動該網站時,它基本上顯示了一些需要的彈出窗口集在我繼續登錄到應用程序之前關閉此特定功能。在關閉所有彈出窗口的代碼中處理了此特定功能,當我繼續單擊登錄按鈕時,登錄按鈕鏈接未被識別並且腳本失敗。如果我評論的彈出窗口代碼,然後登錄按鈕是identified.Please找到下面的代碼相同,好心幫我解決這個問題無法識別使用硒的naukri.com應用程序的登錄按鈕Webdriver
public class naukri {
WebDriver driver = new FirefoxDriver();
@Test
public void pagelaunch() throws InterruptedException{
driver.get("http://www.naukri.com");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String parenthandle = driver.getWindowHandle();
String parent = driver.getWindowHandle();
//close all the pop ups
Set<String> pops=driver.getWindowHandles();
Iterator<String> it =pops.iterator();
while (it.hasNext()){
String popupHandle=it.next().toString();
if(!popupHandle.contains(parent))
{
driver.switchTo().window(popupHandle);
System.out.println("Pop Up Title: "+ driver.switchTo().window(popupHandle).getTitle());
driver.close();
}
}
System.out.println("the system handle is"+parenthandle);
//to click on login button and proceed to login to the application
driver.findElement(By.xpath("//a[@title='Jobseeker Login']")).click();
Thread.sleep(5000);
for(String winhandle:driver.getWindowHandles())
{
driver.switchTo().window(winhandle);
}
driver.findElement(By.xpath("//a[@id='uSel']")).click();
driver.findElement(By.xpath("html/body/div[8]/div[2]/div[2]/form/div[4]/div[2]/input")).sendKeys("anand_qa");
driver.findElement(By.xpath("html/body/div[8]/div[2]/div[2]/form/div[5]/div[2]/input")).sendKeys("test1234");
driver.findElement(By.xpath("//div[8]/div[2]/div[2]/form/div[7]/button")).click();
driver.switchTo().window(parenthandle);
}
}
driver.switchTo()窗口(parenthandle)。作品,並能夠導航到兒童登錄窗口。感謝您的幫助.. !! – Ak17