How do I select elements inside an iframe with Xpath?

后端 未结 1 1790
别那么骄傲
别那么骄傲 2020-12-10 11:35

I want to create a Selenium test to test our extensions with AOL mail. I managed to login to AOL and compose an email, but I also need to select elements inside the editor,

相关标签:
1条回答
  • 2020-12-10 11:37

    You cannot traverse through <iframe>'s until switching to them. Your xPath,

    //iframe[@name='editor_body']//body[@contenteditable='true']
    

    will not work because the <body> tag is within an iFrame, which is not in the current context. you need to switch to it first:

    driver.switch_to.frame('editor_body')...
    
    0 讨论(0)
提交回复
热议问题