0

我正在尝试单击弹出窗口中的按钮-在 Firefox 中有效,但通常在 IE 中无效。当您右键单击窗格时,弹出窗口似乎是 Firefox 中的框架,会出现框架选项

这是在 Firefox 中工作的代码,但在 IE 中,当您 switchto().frame 时它会失败。

Set<String> Windowid = driver.getWindowHandles();
Iterator<String> iter = Windowid.iterator();
String MainWindow = iter.next();
System.out.println(MainWindow);
String DeptWindow = iter.next();
System.out.println(DeptWindow);
driver.switchTo().window(DeptWindow);
String CurrentWindow = driver.getTitle();
System.out.println(CurrentWindow
((JavascriptExecutor) driver).executeScript("onclick=GetDept()");// change DEPT
driver.switchTo().frame("TreeButtons"); // switch to top frame
driver.findElement(By.xpath("//img[@id='DLG_OK']")).click();

我尝试过使用以下内容,但似乎又可以在 Firefox 中使用,但不能在 IE 中使用

WebElement makemytripsearch_btn =(WebElement) ((JavascriptExecutor) driver).executeScript("return document.getElementById('DLG_OK');");
//makemytripsearch_btn.getText();
//System.out.println(makemytripsearch_btn.getText());
 makemytripsearch_btn.click();

我应该从这里去哪里。IE总是有大写T的麻烦

你好,

在 Firefox 中,这里是源代码

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD><TITLE>Department Selection</TITLE>
    </HEAD>
    <FRAMESET BORDER=1 BORDERCOLOR="black" FRAMESPACING=0 ROWS="*,60" OnLoad="opener.PopulateFrames()">
    <FRAME MARGINHEIGHT=0 MARGINWIDTH=2 NORESIZE SCROLLING="AUTO" ID="TreeSelect" NAME="TreeSelect" SRC="blank.htm">
    <FRAME MARGINHEIGHT=7 MARGINWIDTH=10 NORESIZE SCROLLING="NO" ID="TreeButtons" NAME="TreeButtons" SRC="blank.htm">
    <NOFRAMES>
    <BODY><H1 Align=CENTER>Clockwise access issue</H1>
    <P>You do not have FRAMES enabled, please contact your administrator</P></BODY></NOFRAMES>
    </FRAMESET></HTML>

In IE however he is the source code

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Department Selection</TITLE>
<STYLE TYPE="text/css">
<!--
table {margin:0;}
#WaitLayer {position:absolute; top:5; left:7; visibility:hidden; zIndex:3};
-->
</STYLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function Showlayer(lShowit) {WaitLayer.style.visibility =       (lShowit?"visible":"hidden");}
</SCRIPT>
</HEAD>
<BODY BGCOLOR=#ECE9D8><FORM METHOD="POST" NAME="ButtonForm" onSubmit="return false;">
<TABLE COLS=1 ROWS=1 BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN="RIGHT"><TR><TD NOWRAP ALIGN="RIGHT">
<img src="images/dlg_ok.gif?Lang=6153" name="DLG_OK" ID="DLG_OK" width=89 height=33 onClick="return window.parent.opener.DeptSelected()
" onMouseOver="window.status='OK';document.getElementById('DLG_OK').src='images/dlu_ok.gif?Lang=6153';return true;" onMouseOut="window.status='';document.getElementById('DLG_OK').src='images/dlg_ok.gif?Lang=6153';return true;" onMouseDown="window.status='';document.getElementById('DLG_OK').src='images/dlm_ok.gif?Lang=6153';return true;" onMouseUp="window.status='';document.getElementById('DLG_OK').src='images/dlg_ok.gif?Lang=6153';return true;">&nbsp;<img src="images/dlg_cncl.gif?Lang=6153" name="DLG_CANCEL" ID="DLG_CANCEL" width=89 height=33 onClick="return window.parent.opener.CloseDeptPopup()
" onMouseOver="window.status='Cancel';document.getElementById('DLG_CANCEL').src='images/dlu_cncl.gif?Lang=6153';return true;" onMouseOut="window.status='';document.getElementById('DLG_CANCEL').src='images/dlg_cncl.gif?Lang=6153';return true;" onMouseDown="window.status='';document.getElementById('DLG_CANCEL').src='images/dlm_cncl.gif?Lang=6153';return true;" onMouseUp="window.status='';document.getElementById('DLG_CANCEL').src='images/dlg_cncl.gif?Lang=6153';return true;">&nbsp;
</TD></TR></TABLE></FORM>
<SPAN ID="WaitLayer"><H2>Please Wait</H2></SPAN>
</BODY></HTML>

Everything work fine until this line of code below in which Firefox behaves but IE is unable to find the button

driver.switchTo().frame("

TreeButtons"); // switch to top frame
4

0 回答 0