2016-05-31 122 views
0

我遇到的情況,在Add Address buttonAddress Detail Modal dialog window用戶click的出現,無法找到模態對話框窗口中的文本框?

它有4個元素的地址詳細信息兩個文本框和兩個按鈕添加和取消。

我可以直接點擊模型對話窗口中的取消和添加按鈕,但無法找到其中的文本框。

下面是模態對話窗口中文本框的代碼。

input id="Address" class="form-control" type="text" value="" name="Address" data-toggle 
="tooltip" data-placement="bottom" data-bind="value:Address, ValidationMessage: Address" 
data-original-title="" title="" 

如何訪問模式對話框元素的型號爲對話窗口的same window 所以AlertWindow switching methods部分可能是在這種情況下沒有什麼用處? 請任何意見?

更新我想要的示例代碼。

// Click on Address link It open Model window 
driver.findElement(By.xpath(".//div[@id='member_78121']div/table/tfoot/tr/td/div/button")).click(); 
here i am giving wait condition. 
//Inside modal window 
//TextBox first 
driver.findElement(By.id("AddressLine1")).sendKeys("plot no-23"); 
//textbox second 
driver.findElement(By.id("AddressLine2")).sendKeys("plot no-23"); 
//Add button 
driver.findElement(By.id("Add")).click(); 
// driver.findElement(By.id("Cancel")).click(); 
here i am able to click on Add or Cancel button if you comments text boxes code but 
i am getting error for textboxes "element is not visible" 

這是添加按鈕的代碼以供參考

button id="Add" class="btn btn-default" value="Add" type="button" title="" name="Add" 
data-toggle="tooltip" data-placement="bottom" data-bind="click:$parent.SaveAndCloseAddressPopup, Tooltip:$parent.SaveAndCloseAddressPopup" 
data-original-title="Save changes and close" 
+0

錯誤:「元素是不可見的」我試圖等待也 – Eknath

+0

有甚至是其他窗口都不是iframe。 – Eknath

回答

0

//點擊地址鏈接它打開模型窗口

driver.findElement(By.xpath(」 .// DIV [@ 。ID = 'member_78121'] DIV /表/ TFOOT/TR/TD/DIV /鍵「))點擊();

這裏我給等待條件。

//內模態窗口

//TextBox first 
driver.findElement(By.id("AddressLine1")).sendKeys("plot no-23"); 
//textbox second 
driver.findElement(By.id("AddressLine2")).sendKeys("plot no-23"); 
//Add button 
driver.findElement(By.id("Add")).click(); 

// driver.findElement(By.id( 「取消」))點擊()。

在這裏,我能夠點擊添加或刪除按鈕,如果你的評論文本框代碼 但我得到錯誤的文本框「元素是不可見的」

這是添加按鈕的代碼以供參考

按鈕id =「添加」class =「btn btn-default」value =「添加」type =「button」title =「」name =「添加」data-toggle =「tooltip」data-placement =「bottom」data-bind =「click:$ parent.SaveAndCloseAddressPopup,Tooltip:$ parent.SaveAndCloseAddressPopup」data-original-title =「保存更改並關閉」

0
driver.findElement(By.id("AddressLine1")).sendKeys("plot no-23"); 
this try this 
driver.findElement(By.id("Address")).sendKeys("plot no-23"); 

爲您的示例代碼段的輸入框是

input id="Address" class="form-control" type="text" value="" name="Address" data-toggle 
="tooltip" data-placement="bottom" data-bind="value:Address, ValidationMessage: Address" 
data-original-title="" title="" 

在這裏你可以清楚地看到,輸入標籤的ID是地址不AddressLine1

+0

這是我的錯誤在編輯其編號爲「AddressLine1」 – Eknath

+0

好的請發佈確切的html源代碼,否則它變得非常困難,任何人都可以給你正確的答案 –

+0

這是html代碼文本框1 Eknath

相關問題