我已经尝试过使用xpath,csslocator,部分链接文本,但我无法点击注销找不到]
<a href="./ucp.php?mode=logout&sid=d610c2e1bra81y37u7b2co3f4d5ac4f"><img src="./styles/Zoe/te/images/nav.gif" border="0" alt="*"> Logout</a>
任何想法?非常感谢
非常感谢,没有代码,但没有成功:|
1) WebElement link = driver.findElement(By.linkText(" logout")); org.openqa.selenium.NoSuchElementException: No link found with text: logout
2) WebElement link2 = driver.findElement(By.xpath("//a[contains(@href,'mode=logout')]"));
org.openqa.selenium.NoSuchElementException: Unable to locate a node using //a[contains(@href,'mode=logout')]
3) WebElement link = driver.findElement(By.partialLinkText(" logout")); ( didn't work,return the same error)
4)WebElement链接= driver.findElement(By.cssSelector(“ a [href * ='ucp.php?mode = logout'
[src * ='cellnav']”));
org.openqa.selenium.NoSuchElementException:返回的节点(空)不是DOM元素
Webdriver登录时始终返回此错误,但登录有效我可以选择登录的帐户
[Apr 04,2020 10:46:24 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies警告:Cookie被拒绝[phpbb3_n7fab_ct_cookies_test =“%7B%22cookies_names%22%3A%5B%5D%2C%22check_value%22%3A%2220861ca1942e42be32df5e1e9a13b9f2%22%7D”,版本0,域:...。
您可以使用find_element_by_link_text:
例如:
link = driver.find_element_by_link_text(' Logout')
#Or Use Xpath => find link that has certain string in one of it's properties
link = driver.find_element_by_xpath('//a[contains(@href,"mode=logout")]')
要单击它,只需调用单击方法:
link.click()
或使用JavaScript
driver.execute_script("arguments[0].click();", link )