简体   繁体   English

如何使用Java使用Selenium Webdriver单击此注销图标

[英]How to click this Logout Icon using Selenium Webdriver using Java

I am working on a banking portal which have Div structure for logout in below given 我正在一家银行门户网站上工作,该门户网站具有以下给出的注销结构:

<div class ="bar bar-desktop small-12 columns">
 <a id="j_idt39:logoutMenu" terminatevbsess="" href="javascript:void(0);" class="icon-logout" ng-click="click($event,{s:&quot;j_idt39:logoutMenu&quot;,p:&quot;menUid&quot;,u:&quot;menUid&quot;});">
  ::before
  <i class="icon left "></i>
 </a>
</div>

When I identify Logout Icon :: before is being highlighted. 当我确定注销图标:: before突出显示时。 Please let me know how I can identify and how to select locator for this icon. 请让我知道如何识别以及如何为该图标选择定位器。

You can use cssSelector to find the logout icon. 您可以使用cssSelector查找注销图标。 try using driver.findElement(By.cssSelector(".icon-logout")).click() 尝试使用driver.findElement(By.cssSelector(".icon-logout")).click()

Get xpath using Firepath and click on Logout button that is a tag. 使用Firepath获取xpath,然后单击作为标签的注销按钮。

driver.findElement(By.xpath("")).click(); driver.findElement(By.xpath(“”))。click();

In your html code you cannot find id easily because some problem in html code. 在您的html代码中,您无法轻易找到id,因为html代码中存在一些问题。

You can use LinkText: 您可以使用LinkText:

driver.FindElement(By.LinkText("::before")).click(); driver.FindElement(By.LinkText(“ :: before”))。click();

You can try this: 您可以尝试以下方法:

WebElement element = driver.findElement(By.cssSelector("a.icon-logout > i");
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 selenium-webdriver 和 Java 单击日历图像图标 - How to click the Calendar image icon using selenium-webdriver and Java 无法使用Selenium Webdriver 3.0.1单击注销链接 - Unable to click on the logout link using selenium webdriver 3.0.1 如何使用带有Java的Selenium WebDriver多次单击同一按钮 - How to click on a same button multiple times using Selenium WebDriver with Java 如何使用Selenium WebDriver和Java根据HTML单击复选框 - How to click on the checkbox as per the HTML using Selenium WebDriver and Java 如何使用Selenium Webdriver 2.25-Java单击ahref链接? - How to click on the ahref link using selenium webdriver 2.25 - java? 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击允许按钮 - How to click on allow button on popup window in selenium Webdriver by using Java 如何<a class </a>在Selenium WebDriver中使用Java</a>单击带有标签名称的链接 - How to click a link with Tag name <a class </a> using Java in Selenium WebDriver 如何使用Selenium WebDriver(Java)单击图像/链接 - How to click on an image/link using Selenium WebDriver (Java) 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击按钮 - How to click on button on Popup Window in Selenium Webdriver by using Java 如何使用XPath不是常数的Selenium WebDriver Java单击按钮 - How to click button using selenium webdriver java, whose xpath is not constant
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM