[英]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:"j_idt39:logoutMenu",p:"menUid",u:"menUid"});">
::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.