Selenium Webdriver - (Java) - working with HTML di

2019-09-06 01:24发布

Here is the situation:

  1. Click on Import file button (this action will upload a file).
  2. After file upload, then appears a popup (HTML popup). I used driver.switchTo().frame(1); to switch to that popup and click "Next" in that popup.
  3. Clicking Next will navigate user to second step in that popup. Click process commission button in that second step of popup.
  4. After clicking process commission button, then appears a new confirmation popup (HTML popup).
  5. I am not able to click yes in that confirmation popup.

I tried using:
driver.switchTo().frame(0); - did not work
driver.switchTo().frame(1); - did not work
driver.switchTo().frame(2); - did not work

Please suggest any solution.

<form id="Form1" enctype="multipart/form-data" action="ProcessCommission.aspx?i=2115&pn=Manage+Commission&j=2345&prn=Process+Commission" method="post">
<iframe scrolling="no" frameborder="0" src="javascript:'<html></html>';" style="position: fixed; width: 400px; height: 100px; left: 431px; top: 53px; background-color: rgb(255, 255, 255); z-index: 3003;" tabindex="-1">  
<div id="RadWindowWrapper_confirm1381733327500" class="RadWindow RadWindow_Windows7 rwNormalWindow rwTransparentWindow" style="width: 400px; height: 100px; position: absolute; transform: none; backface-visibility: visible; visibility: visible; left: 431px; top: 377px; z-index: 3003;" unselectable="on">  
<table class="rwTable" cellspacing="0" cellpadding="0" style="height: 51px;">  
<tbody>  
<tr class="rwTitleRow">  
<tr class="rwContentRow">  
<td class="rwCorner rwBodyLeft"> </td>
<td class="rwWindowContent" valign="top">  
<iframe frameborder="0" name="confirm1381733327500" src="javascript:'<html></html>';" style="width: 100%; height: 100%; border: 0px none; display: none;" tabindex="0">  
<div id="confirm1381733327500_content">  
<div class="rwDialogPopup">  
<div class="rwDialogText">  
<div>
<a class="rwPopupButton" href="javascript:void(0); "onclick="$find('confirm1381733327500').close(true);" tabindex="-1">
<span class="rwOuterSpan">  
<span class="rwInnerSpan">Yes</span>  
</span>
</a>  
<a class="rwPopupButton" href="javascript:void(0);" onclick="$find('confirm1381733327500').close(false);" tabindex="-1">  
<span class="rwOuterSpan">  
<span class="rwInnerSpan">No</span>  
</span>

2条回答
欢心
2楼-- · 2019-09-06 01:47

Try this:

driver.switchto.frame(0)
driver.switchto.frame(confirm1381733327500)
查看更多
放荡不羁爱自由
3楼-- · 2019-09-06 01:51
dr.SwitchTo().Frame(dr.FindElement(By.TagName("iframe")));
dr.SwitchTo().DefaultContent();
dr.FindElement(By.XPath("your stuff goes here").Click();
dr.SwitchTo().DefaultContent();//switch back to default content of original page
查看更多
登录 后发表回答