gpt4 book ai didi

selenium-webdriver - Java Selenium-webdriver : Enter the text into the text area

转载 作者:行者123 更新时间:2023-12-04 02:43:43 27 4
gpt4 key购买 nike

附上图片更多详情请关注::![我想在文本区域输入文字:照片中提到][1][1]:http://i.stack.imgur.com/sai92.png我想在文本区域中输入文本,但出现找不到元素的错误。我已经尝试使用 X 路径、名称和 ID,但无法执行此代码,并且想与页面上出现的其他元素一起玩以进行测试,但什么也没有!!!我不知道它可以用 java-executor 或切换窗口(弹出)来处理。下面提到的是 java 代码。如何处理这种情况,请提供详细信息。

Java代码:

@Test   
public void CreteLead() throws InterruptedException
{
WebElement _loginName =
driver.findElement(By.xpath(OR.getProperty("username")));

_loginName.sendKeys(OR.getProperty("loginId"));

WebElement _password =
driver.findElement(By.xpath(OR.getProperty("password")));
_password.sendKeys(OR.getProperty("loginPassword"));
WebElement _login =
driver.findElement(By.xpath(OR.getProperty("login")));

_login.click();
Thread.sleep(5000);

WebElement _New =
driver.findElement(By.xpath(OR.getProperty("New")));

_New.click();
Thread.sleep(10000);
driver.findElement(By.id("btnCreateCustomer")).click();

HTML代码:

<table class="tbl_top_align" width="100%" cellspacing="3" cellpadding="0">
<tbody>
<tr>
<tr>
<tr>
<tr id="trBranch">
<tr id="trAssign">
<td> Assign To*: </td>
<td>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="font-weight: normal !important;">
<div
id="ctl00_CPHPageContents_ctl00_CPHPageContents_ddlAssignedToPanel"
class="RadAjaxPanel" style="display: block;"
>
<span id="RequiredFieldValidator1"
class="error_message" style="display:none;"
>* missing</span>
</td>
<td style="vertical-align: middle !important;">
<td style="vertical-align: middle !important;"> Referral </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="padding: 4px 0 5px;"> Follow-up on: </td>
<td style="padding: 4px 0 5px;">
<a id="btnFollowUp"
href="javascript:__doPostBack('ctl00$CPHPageContents$btnFollowUp','')"
>Not Scheduled</a>
</td>
</tr>
<tr>
<td> Account: </td>
<td>
<span id="ctl00_CPHPageContents_txtAccount_wrapper"
class="riSingle RadInput RadInput_Default" style="width: 160px;">
</td>
</tr>
<tr>
<td> Value: </td>
<td>
<span id="ctl00_CPHPageContents_txtAccountValue_wrapper"
class="riSingle RadInput RadInput_Default" style="width: 125px;">
</td>
</tr>
<tr>
<td>Description*:</td>
<td>
<textarea id="txtInstructions" class="schedule_notes"
style="height: 95px; width: 294px !important;" cols="20" rows="2"
name="ctl00$CPHPageContents$txtInstructions"
/>
<span id="RequiredFieldValidator2" class="error_message"
style="display:none;">* missing</span>
</td>
</tr>
<tr>
</tbody>
</table>
<div class="action_buttons">
</div>

最佳答案

我在 textarea 上遇到过类似的问题,如果你可以sendkeysprevious input field,只需使用TAB 移动到下一个字段(文本区域)并输入文本,这对我有用

driver.findElement(By.id("id_of_previous_input_field")).sendKeys(Keys.TAB,"This text will appear in textarea");

关于selenium-webdriver - Java Selenium-webdriver : Enter the text into the text area,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19312958/

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