gpt4 book ai didi

node.js - Webdriver - 如何通过 xpath/css 访问某些特定的 iFrame

转载 作者:太空宇宙 更新时间:2023-11-04 01:52:05 25 4
gpt4 key购买 nike

我无法通过selenium(node js + mocha)访问下面网站中的某些iFrame -

https://www.rt.com/uk/421078-may-skripal-russia-parliament/

所需的 iframe 元素 -

<iframe id="5645d42cb79d139a24d943622da2c47d-iframe" src="https://spoxy-shard5.spot.im/v2/spot/sp_6phY2k0C/post/421078/?elementId=b2ec2c94ee1c35810c76e1704dbe3d06&amp;spot_im_platform=desktop&amp;host_url=https%3A%2F%2Fon.rt.com%2F90wm&amp;host_url_64=aHR0cHM6Ly9vbi5ydC5jb20vOTB3bQ%3D%3D&amp;spot_im_ph__prerender_deferred=true&amp;prerenderDeferred=true&amp;sort_by=best&amp;isStarsRatingEnabled=false&amp;enableMessageShare=true&amp;enableAnonymize=false&amp;isConversationLiveBlog=false&amp;enableSeeMoreButton=true" scrolling="no" style="overflow: hidden; height: 2339px;" data-frame-unique-id="a6cbebb1116a32e10263270bfde7e0c1" data-conversation-id="sp_6phY2k0C_421078"></iframe>

我想将 key 发送到其中的输入元素 -

enter image description here

请您帮忙,谢谢。

最佳答案

您可以使用以下任一选项切换到特定框架:

  • CSS:

    iframe[id$='-iframe'][src^='https://spoxy-shard5.spot.im/v2/spot/sp_']
  • XPATH:

    //iframe[contains(@id,'-iframe') and starts-with(@src,'https://spoxy-shard5.spot.im/v2/spot/sp_')]

Note : You may require to induce wait for the intended frame to be available and switch to it. You will find a detailed discussion in How can I select a html element no matter what frame it is in in selenium?. See the A Better Approach to Switch Frames section.

关于node.js - Webdriver - 如何通过 xpath/css 访问某些特定的 iFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49280713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com