简体   繁体   English

无法点击退出按钮

[英]Not able to click on SignOut button

need your help! 需要你的帮助! I am not able to click on 'Sign Out', here is the snapshot from Firebug: 我无法点击“退出”,这是Firebug的快照:

<li class="dropdown open">
<a class="dropdown-toggle" aria-expanded="true" aria-haspopup="true" role="button" data-toggle="dropdown" href="#">
<ul class="dropdown-menu">
<li class="dropdown-header">email_id@xyz.com</li>
<li class="signout">
<form id="form0" class="" method="post" action="/_Account/Logout">
<input type="hidden" value="mkEfSz6-X9flSbOQ6IA39rVPnHnX6gethyjNrisgAcWerf0QL7oaL1zaTFC5j9omCdvfTtjEICuRqpuPjIiiHmnog5EOBMeOHkXD7ccphD8d6BISw46JmAYfm5ZrMksC0oe91g2" name="__RequestVerificationToken">
<input class="btn btn-block btn-primary btn-block" type="submit" value="Sign Out">
</form>
<script type="text/javascript">

Have tried: 试过:

driver.findElement(By.xpath("//div/ul[2]/li/ul/li[2]")).click();

driver.findElement(By.xpath("//input[@value='Sign Out']")).click();

this as well (not sure if this is right): 也是如此(不确定是否正确):

Select DropdownList = new Select(driver.findElement(By.xpath("//form[@id='form0']/input[2]")));
DropdownList.selectByVisibleText("Sign Out");

尝试像这样:

driver.findElement(By.xapth("//form[contains(@id, 'form0')]/input[contains(@class, 'btn')]")).click;

The element seems to be hidden so that's your first hurdle but try the below and see if that works. 该元素似乎已隐藏,因此这是您的第一个障碍,请尝试以下操作,看看是否可行。 You may have to go up (or down) another level to get it to work. 您可能必须向上(或向下)另一级才能使其正常工作。 ps. ps。 I haven't run the code so watch out for any errors. 我没有运行代码,所以请注意是否有任何错误。

driver.findElement(By.cssSelector("li[class='signout'] class[value='Sign Out']")).click(); driver.findElement(By.cssSelector(“ li [class ='signout'] class [value ='Sign Out']”))。click();

I think you are specifying the element correctly but let's try a CSS Selector. 我认为您正确指定了元素,但让我们尝试CSS选择器。

    driver.findElement(By.cssSelector("input[value='Sign Out']")).click();

If that doesn't work, try this just to see if there is another element that it's finding by accident. 如果这不起作用,请尝试这样做,以查看是否偶然发现了另一个元素。 The return here should be 1. 这里的收益应该是1。

    System.out.println(driver.findElements(By.cssSelector("input[value='Sign Out']")).size());

Is there a SELECT dropdown near this Sign Out button? 该“退出”按钮附近是否存在SELECT下拉列表? I have this hunch that Selenium is trying to click on your INPUT tag but it's somehow clicking a SELECT tag. 我有这样的预感,Selenium试图单击您的INPUT标记,但是以某种方式单击了SELECT标记。 Maybe it's not visible or something??? 也许它不可见或什么?

Let's also check to see if this element is within an IFRAME . 我们还要检查一下此元素是否在IFRAME What does this return? 这会返回什么? Hopefully 0. 希望0。

    System.out.println(driver.findElements(By.cssSelector("iframe input[value='Sign Out']")).size());

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM