简体   繁体   中英

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:

<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. I haven't run the code so watch out for any errors.

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.

    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.

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

Is there a SELECT dropdown near this Sign Out button? I have this hunch that Selenium is trying to click on your INPUT tag but it's somehow clicking a SELECT tag. Maybe it's not visible or something???

Let's also check to see if this element is within an IFRAME . What does this return? Hopefully 0.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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