gpt4 book ai didi

java - 如何在另一个 html 标签内选择带有 html 源的 web 元素 selenium web 驱动程序

转载 作者:行者123 更新时间:2023-11-30 16:58:53 25 4
gpt4 key购买 nike

<html>
<head></head>
<body>
<div id="title"></div>
<div id="credit"></div>
<div id="btnFS"></div>
<div id="cont">
<div id="fscont">
<div style="font-size: 0px; position: absolute; left: 0; right: 0; top: …w: auto; overflow-y: auto; -webkit-overflow-scrolling:touch;"></div>
<div style="font-size: 0px; position: absolute; left: 0; right: 0; height: 75px; overflow: hidden; bottom: 0;">
<iframe width="100%" height="100%" frameborder="0" name="cboxform" scrolling="no" marginwidth="0" marginheight="0" src="//www4.cbox.ws/box/?boxid=4255329&boxtag=ev9nj4&sec=form" allowtransparency="yes">
#document
<!DOCTYPE html>
<html style="position: absolute; height: 100%; width: 100%; overflow: hidden; margin: 0px; padding: 0px;">
<head></head>
<body class="fmbdy" style="padding: 0px; margin: 0px;">
<form class="cfrm" onsubmit="return do_post();" method="post" action="./?boxid=4255329&boxtag=ev9nj4&sec=submit" target="cboxmain" name="cbox">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" style="width: auto;">
<tbody>
<tr></tr>
<tr>
<td id="tblmid" valign="top" style="vertical-align: top; white-space: nowrap; font-size: 0;" colspan="2">
<input type="hidden" value="" name="key"></input>
<input class="frmtb" type="text" onblur="frmblur(this, 'name');" onfocus="frmfocus(this, 'name');" value="name" size="9" autocomplete="off" spellcheck="false" name="nme" maxlength="25" style="box-sizing: content-box; width: 301px;"></input>

我有一个聊天框页面,它是由 cbox.ws 创建的,我想选择这个页面上的元素。
我尝试了很多方法在此网站中选择 id tblmid 但我不能。
使用了很多方法,例如通过名称获取、查找 xpath 然后通过 xpath 获取、通过 css 查找和获取它们……但它没有用。

我怎样才能得到那个元素?我正在使用java。
我试着一步一步地 get by id cont -> get by id fscont -> get by name cboxform 但我不能再去了,卡在这里。

WebElement inputName = driver.findElement(By.id("cont"));
inputName = inputName.findElement(By.id("fscont"));
inputName = inputName.findElement(By.name("cboxform"));

非常感谢。

最佳答案

所需的元素在 iframe 中,您需要在进行搜索之前切换到它:

driver.switchTo().frame("cboxform");

driver.findElement(By.id("tblmid"));

另见:

关于java - 如何在另一个 html 标签内选择带有 html 源的 web 元素 selenium web 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29224281/

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