How to deal with ModalDialog using selenium webdriver?

后端 未结 8 1764
天命终不由人
天命终不由人 2020-12-01 14:33

I am unable to switch to Modal Dialog of given example

http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm

I don\'t kno

8条回答
  •  醉酒成梦
    2020-12-01 15:18

    Solution in R (RSelenium): I had a popup dialog (which is dynamically generated) and hence undetectable in the original page source code Here are methods which worked for me:

    Method 1: Simulating Pressing keys for Tabs and switching to that modal dialog My current key is focussed on a dropdown button behind the modal dialog box
    remDr$sendKeysToActiveElement(list(key = "tab"))
    Sys.sleep(5)
    remDr$sendKeysToActiveElement(list(key = "enter"))
    Sys.sleep(15)
    
    Method 2: Bring focus to the frame(or iframe) if you can locate it
    date_filter_frame <- remDr$findElement(using = "tag name", 'iframe')
    date_filter_frame$highlightElement()
    
    Sys.sleep(5)
    
    remDr$switchToFrame(date_filter_frame)
    
    Sys.sleep(2)
    
    Now you can search for elements in the frame. Remember to put adequate Sys.sleep in between commands for elements to load properly (just in case)
    date_filter_element <- remDr$findElement(using = "xpath", paste0("//*[contains(text(), 'Week to Date')]"))
    date_filter_element$highlightElement()
    

提交回复
热议问题