gpt4 book ai didi

java - 选择与 Selenium Webdriver 的链接?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:08:53 24 4
gpt4 key购买 nike

如何使用 selenium webdriver 选择链接?

Selenium 之前将由以下人员完成:

    selenium.click("link=Users");

但是我怎样才能对 webdriver 做同样的事情呢?

我想过

    driver.findElement(By.partialLinkText("Users")).click();

但这行不通。没有链接被点击!

<html>
<body>
<div id="mainpage" class="mainpage">
<div id="pageid" class="pageid">
<div id="body">

<table>
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td>
<div id="id_menu" class="mymenu">
<ul>
<li class="li_class ">
<a href="/user.xhtml">Users</a>

堆栈跟踪:

    org.openqa.selenium.NoSuchElementException: Unable to locate element: 
{"method":"partial link text","selector":"Users"} Command duration or timeout: 11.36
seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions
/no_such_element.html Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
17:28:14' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.7.0_02' Driver info: driver.version: RemoteWebDriver Session ID:
178449d1-4ff3-44f3-b35c-6a158db7c430 error at line: 34

最佳答案

这应该有效:

driver.findElement(By.LinkText("Users")).click();

通过 LinkText 是可能的

关于java - 选择与 Selenium Webdriver 的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12090084/

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