Pop up logout button - xpath

In my application, logging out is a two way process. When you click on the Logout link on the main screen, it opens up a pop-up for confirmation of logout.
Now, on pop-up, there are two button ( 'Logout' and 'Cancel'). The problem is that I am not able to click on either of them.
Using Firebug console, I confirmed that the XPath which I am using is correct. But when using the same Xpath in webdriver, it's not able to locate the object.
Xpath of the button on the pop-up : //div[3]/div/div/div[2]/div/a/span
Code which I am trying :
IWebElement LogoutButton = WebDriver.FindElement(By.XPath("//div[3]/div/div/div[2]/div/a/span"));
LogoutButton.Click();
Is there any specific method to use here ?? Please let me know.
cheers
EDIT*
<div id="ext-comp-1084" class="x-window x-layer x-window-default x-closable x-window-closable x-window-default-closable x-popup" tabindex="-1" style="opacity: 1; width: 250px; height: 145px; right: auto; left: 755px; top: 147px; z-index: 19000;">
<div id="ext-comp-1084_header" class="x-window-header ext-header ext-header-horizontal x-docked x-unselectable x-window-header-default x-horizontal x-window-header-horizontal x-window-header-default-horizontal x-top x-window-header-top x-window-header-default-top x-docked-top x-window-header-docked-top x-window-header-default-docked-top" style="width: 250px; right: auto; left: 0px; top: 0px;">
<div id="ext-comp-1084-body" class="x-window-body x-window-body-default x-closable x-window-body-closable x-window-body-default-closable x-window-body-default x-window-body-default-closable" style="width: 250px; left: 0px; top: 52px; height: 49px;">
<div id="toolbar-1086" class="x-toolbar x-docked x-toolbar-default x-docked-bottom x-toolbar-docked-bottom x-toolbar-default-docked-bottom x-box-layout-ct" style="width: 250px; right: auto; left: 0px; top: 101px;">
<div id="toolbar-1086-innerCt" class="x-box-inner " role="presentation" style="width: 250px; height: 44px;">
<div id="toolbar-1086-targetEl" class="x-box-target" style="width: 250px;">
<div id="tbspacer-1087" class="x-toolbar-spacer x-box-item x-toolbar-item x-toolbar-spacer-default" style="right: auto; left: 0px; margin: 0px; width: 50px; top: 22px;"></div>
<div id="button-1088" class="x-btn green x-exclude x-unselectable x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" style="border-width: 1px; width: 100px; right: auto; left: 50px; margin: 0px; top: 8px;">
<div id="button-1088-btnWrap" class="x-btn-wrap" unselectable="on">
<a id="button-1088-btnEl" class="x-btn-button" tabindex="0" unselectable="on" hidefocus="on" role="button">
<span id="button-1088-btnInnerEl" class="x-btn-inner x-btn-inner-center" unselectable="on">Logout</span>
<span id="button-1088-btnIconEl" class="x-btn-icon-el " style="" unselectable="on" role="img"></span>
</a>
</div>
</div>
<div id="button-1089" class="x-btn gray x-exclude x-unselectable x-box-item x-toolbar-item x-btn-default-toolbar-small x-noicon x-btn-noicon x-btn-default-toolbar-small-noicon" style="border-width: 1px; width: 80px; right: auto; left: 160px; margin: 0px; top: 8px;">
<div id="button-1089-btnWrap" class="x-btn-wrap" unselectable="on">
<a id="button-1089-btnEl" class="x-btn-button" tabindex="0" unselectable="on" hidefocus="on" role="button">
<span id="button-1089-btnInnerEl" class="x-btn-inner x-btn-inner-center" unselectable="on">Cancel</span>
<span id="button-1089-btnIconEl" class="x-btn-icon-el " style="" unselectable="on" role="img"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>

1) First save the instance of main window using below code
String mainWindow = driver.getWindowHandle();
2) //code to click on the Logout link on the main screen
3) then switch webdriver control to pop-up using below code
for(String childWindow : driver.getWindowHandles()){
driver.switchTo().window(childWindow);
}
4) //code to click on pop-up, ( 'Logout' and 'Cancel').

Related

What is the trick getting floats to work in FireFox other than (moz-inline-stack and float first)

I can't get things to float correctly in firefox.
If you open it in FireFox you will notice its all on top of itself.
But it works fine in IE, and Chrome.
I may be doing it wrong, but you can see I have tried moz-inline-stack, and putting the float elements first.
Here is a Fiddle link.
https://jsfiddle.net/james_freeman/zWxbL/10/embedded/result/
<div style="background-color:white;">
<div id="psNav" style="color: #0475b8;">
<div class="psNav-right dropdown">
<a href="#" id="navbarMenu" class="dropdown-toggle psNav-link" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false">MENU <i class="fa fa-bars"></i>
</a>
<ul class="dropdown-menu" style="padding:0;">
<li>Conversations
</li>
<li>Directory
</li>
</ul>
</div>
<div class="psNav-right"> <a class="psNav-link" id="logoutLink" href="">Logout</a>
</div>
<div class="psNav-right"> <a class="psNav-link" id="displayName">Doe, John</a>
</div>
<div class="psNav-left"> <a class="psNav-link" href="">
<img id="navBarLogo" src="" alt="Company Logo">
</a>
</div>
<div class="psNav-center"> <a class="psNav-link" id="navbarPageTitle">somewhere</a>
</div>
</div>
</div>
#psNav {
display: inline-block;
display: -moz-inline-stack;
vertical-align: top;
width: 100%;
text-align: center;
height: 90px;
clear: both;
font-family:'Source Sans Pro', sans-serif;
font-weight: 600;
font-size: 1.5em;
border-bottom-color: #e7e7e7;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
*display: inline;
}
.psNav-center {
display: inline-block;
display: -moz-inline-stack;
margin: 0 auto;
height: inherit;
}
.psNav-left {
float: left;
height: inherit;
padding-left: 10px;
}
.psNav-right {
float: right;
height: inherit;
padding: 0 20px 0 20px;
}
.psNav-link {
vertical-align: middle;
line-height: 85px;
text-decoration: none !important;
}
.psNav-link:visited {
color: #0475b8;
}
.psNav-link:hover {
color: #0475b8;
}
.psNav-link:active {
color: #0475b8;
}
#displayName {
cursor: default;
font-weight: 300;
}
#navbarPageTitle {
cursor: default;
}
#navBarLogo {
height: 55px;
}
I'm not sure what you thought -moz-inline-stack was going to achieve, but it is the cause of your broken layout.
Removing it from the fiddle results in the layout returning to exactly what how it looks in the other browsers.

JQ Grid: Checkbox not posting value while adding or editing Record

I am using customized check box icheck in JQ Grid edit and add form but checkbox element is not getting posted to the server even it is checked.
Here is the generated markup for the form:
`<td class="CaptionTD">
Status
</td>
<td class="DataTD">
<div style="position: relative;" id="userGroupBean.isActive_icheck" class="icheckbox_square-green checked">
<input title="" style="position: absolute; opacity: 0;" class="FormElement" role="checkbox" name="userGroupBean.isActive" id="userGroupBean.isActive" offval="0" value="1" checked="" type="checkbox">
<ins style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;" class="iCheck-helper"></ins>
</div>
</td>`

Can't find an appropriate xpath directory. Need some advice

<div>
<div class="dates">
So, to find the dates class above, I'm using $x("//div[#class= 'dates']//") but console says that this expression is illegal expression.
<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;">
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 0px;">
<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;">
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 91px;">
<ul id="DateList" class="bxslider clearfix" data-bx-slider="mode: 'horizontal', pager: false, controls: false, minSlides: 1, maxSlides:4, slideWidth: 290, slideMargin:0, hideControlOnEnd:true, infiniteLoop: false, moveSlides: 1" style="width: 515%; position: relative; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);">
To find the correct xpath to the above node, I'm using $x("//ul[#id= 'DateList']//") and still got a message that expression is illegal.
<li class="date-block slide ng-scope" data-notify-when-repeat-finished="" ng-repeat="dates in cruiseFinder.filters.sailDates" style="float: left; list-style: outside none none; position: relative; width: 290px;">
<h5 class="ng-binding">2015</h5>
<ul id="months" class="months">
In both cases the last double slash is too many: The right xpaths would be:
//div[#class= 'dates']
//ul[#id= 'DateList']
Double slash into a xpath expression means "in any place of the document".

twitter bootstrap columns not clearing

I have a three column layout where the logo at browser view is to the left, one word is in the middle, and the nav menu is to the right. This is fine at full browser.
When it is resized to mid or mobile view the columns are not clearing and stacking correctly.
Here is what I am getting right now at full view: http://postimg.org/image/wvfl1hkut/
Here is what needs fixed at mobile and mid view: http://postimg.org/image/sa1nvyw8j/
Here is my code:
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="row">
<div class="header">
<div class="col-xs-6 col-sm-4">
<a href="{{ URL::route('home') }}">
<div class="header_group">
<img src="../../images/logo.png">
</div><!--header group -->
</a>
</div>
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-4">
<p> </p>
</div>
<div class="col-xs-6 col-sm-4">
#include('layout.navigation')
</div>
</div><!-- main header -->
</div><!-- row -->
</div>
</div>
External CSS sheet
.header {
width: 100%;
height: auto;
margin: 0 auto;
background: red;
}
.header_group {
background-color: none;
width: 100%;
height: auto;
display: inline-table;
font-size: 1.5em;
font-weight: 400;
font-family: 'Roboto', sans-serif;
color: #f0fff0;
clear: none;
margin-top: 5%;
}
.header_text {
vertical-align: middle;
display: inline;
text-align: center;
color: #f05152;
}
.nav {
width: auto;
height: auto;
margin-top: 12%;
}
.nav a {
color: #000;
padding-left: 10%;
margin-left: 4%;
}
.navbar {
width: 100%;
height: 20%;
padding-top: 0;
}
.wrapper {
width: 100%;
height: 500px;
background: url(../../../images/yellow.png) repeat,
}
Bootstrap has a 12 column grid. Each set of 12 columns should be contained in a .row.
Your code has 4 .col-xs-6 columns, which total 24 columns. It also has 3 .col-sm-4 and 1 .col-sm-3 columns, which total 15 columns.
If you place the columns in their correct rows of 12 then they will clearfix correctly.
FYI: From the documentation...
Content should be placed within columns, and only columns may be immediate children of rows.
Move .header.

Images on nav bar before each link

Right, so I have made a navigation bar and I want to add images before each link, I know I can use a.header:before but I need different images for each link, a house for home, spanner for spec and so on. What is the simplest way of doing this? Is there a way without creating a div for each one and styling them individually?
For a preview of the page so far with the nav - http://zimxtrial.ukbigbuy.com/
One more thing - here is part of the css:
#header-nav {
background-color: #FFFFFF;
height: 80px; height: 8.0rem;
width: 100%;
position: absolute;
top: 50px;
}
.header-nav-center {
height: 80px; height: 8.0rem;
text-align: center;
position: relative;
top: 0px;
width: 500px; width: 50.0rem;
margin-left: auto;
margin-right: auto;
}
.header-nav-center ul {
margin: 0;
}
.header-nav-center ul li {
list-style: none;
margin: 0 35px 0 0;
display: inline;
}
a.header {
line-height: 80px; line-height: 8.0rem;
font-size: 17px; font-size: 1.7rem;
}
And HTML:
<div id="home">
<div id="header-nav">
<div id="hr-nav-top-container">
<hr class="nav" />
</div>
<div id="logo"></div>
<div class="header-nav-center">
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li><a class="header" href="#features">Features</a>
</li>
<li><a class="header" href="#specification">Specification</a>
</li>
<li><a class="header" href="#contact-us">Contact Us</a>
</li>
</ul>
</div>
<div id="pre-order"></div>
<div id="hr-nav-bottom-container">
<hr class="nav" />
</div>
</div>
</div>
Can I add something like:
a.header.home:before {
background: url('../images/home-logo.png') center center no-repeat;
}
Not that exactly but something like it?
You could make ids for each link and add the ids to the desired link img

Resources