gpt4 book ai didi

testing - 在 Selenium 中处理子窗口

转载 作者:行者123 更新时间:2023-11-28 20:00:25 29 4
gpt4 key购买 nike

我正在尝试使用 TestNG 访问 VCM 中的二级弹出窗口,即我单击父窗口上的“添加”按钮,它会打开,然后我有其他字段可以添加到子内容中,但我无法选择子内容窗口。

这是我的代码:

    selenium.open("http://xyz.com/AppConsole");
selenium.type("name=j_username", "username");
selenium.type("name=j_password", "password!");
selenium.click("id=vign-login-button");
selenium.waitForPageToLoad("30000");
selenium.click("id=href_consoleMenus30");
selenium.waitForPageToLoad("30000");
selenium.click("link= Contents");
selenium.waitForPageToLoad("30000");
selenium.click("id=href_VignConsoleForm");
selenium.waitForPopUp("createContentInstance_undefined", "30000");
selenium.selectWindow("name=createContentInstance_undefined");
selenium.click("link=XYZ");
selenium.waitForPageToLoad("30000");
selenium.click("id=o12_hierarchyBrowserForm");
selenium.click("name=cmdOK");
selenium.waitForPageToLoad("30000");
selenium.type("id=ce_f508VgnVCM____", "Testing");
selenium.select("id=ce_060859310VgnVCM____", "label=Counting");
verifyTrue(selenium.isTextPresent("Forms"));
selenium.click("name=coe_relator_butn_add_2468d");
selenium.waitForPopUp("Add/Edit", "90000");
selenium.selectWindow("Add/Edit");
verifyEquals(selenium.getTitle(), "Add/Edit");

最佳答案

我认为您可以按如下方式修改代码,它可能会正常工作。

   selenium.click("name=coe_relator_butn_add_2468d");
try{
Thread.sleep(5000);
}catch(Exception e){
}
String titles = selenium.getAllWindowTitles();
int i =0;
while(i<titles.length){
if(titles[i].equalsIgnoreCase("Add/Edit"))
break;
i++;
}
selenium.selectWindow(titles[i]);

关于testing - 在 Selenium 中处理子窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13121921/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com