selenium isVisible method not working as expected - selenium

I am opening this page http://www.ebay.com/itm/Apple-iPhone-5-16GB-White-Silver-Factory-Unlocked-/151097083750?pt=Cell_Phones&hash=item232e168766
and checking to see if the blue ribbon is visible as mentioned in the image
Here is my test
<tr>
<td>open</td>
<td>/itm/Apple-iPhone-5-16GB-White-Silver-Factory-Unlocked-/151097083750?pt=Cell_Phones&hash=item232e168766</td>
<td></td>
</tr>
<tr>
<td>isVisible</td>
<td>//div[#class='vi-notify-msg']</td>
<td></td>
</tr>
And expecting it to fail but surprisingly it passes every time...what am i missing here?
EDIT:
I am expecting the test to fail because the ribbon takes time to appear after the page is loaded and the command isVisible executed before the ribbon is visible..so it should fail right?

If you look at the HTML, the element is there as the page loads. It's only styled to fade in after the page finishes loading, but from an HTML perspective, it's "visible" the entire time the page is loading:
As the page is loaded:
<div id="vi_notification" class="vi-notify-cmp" style="top:25%;">
<div class="vi-notify-container vi-notify-shadow">
<div class="vi-notify-icon vi-notify-icon-img"></div>
<div class="vi-notify-msg">28 people are viewing this item per hour.</div>
<div class="vi-notify-close">
<button id="vi_notification_cls_btn" class="vi-notify- close-btn">x</button>
</div>
</div>
</div>
Only after it fades out does the styling change to display:none:
<div id="vi_notification" class="vi-notify-cmp" style="top: 25%; left: 10px; display: none;">
<div class="vi-notify-container vi-notify-shadow">
<div class="vi-notify-icon vi-notify-icon-img"></div>
<div class="vi-notify-msg">28 people are viewing this item per hour.</div>
<div class="vi-notify-close">
<button id="vi_notification_cls_btn" class="vi-notify-close-btn">x</button>
</div>
</div>
</div>
If you look at the element as it loads using the Chrome Developer toolbar, you'll see where it is "visible", but the styling updates to slowly fade it in so our human eyes can see it.
This means that when the page is loading / loaded, the element will return as displayed. After it fades out, I would expect displayed to return false, since the styling on the parent div was changed to display:none.

Related

vue dom doesn't re-render

I use v-for to render table rows
<table>
<tr v-for="(item, i) in data">
<td>
<button v-if="...">....</button>
<el-tooltipplacement="right">
<button v-if="..." >...</button>
<div slot="content">
<button #click="...">...</button>
<button #click="...">...</button>
</div>
</el-tooltip>
</td>
</tr>
</table>
The tooltip is a component of element ui,
the tooltip will display after hovering the button.
The table data is gotten by ajax call,
and there are several pages,
it will get the data by ajax call while turning page,
the problem occurs after turning page.
Some tooltip will not display after hovering,
I assumed the problem is doms don't re-render,
I used $forceUpdate() after ajax call,
but it had no effect.
If you can please help me out.
element ui Tooltip component and exmaple: https://element.eleme.io/#/en-US/component/tooltip

Hidden div takes up height in Bootstrap modal body

I have a div inside of a Bootstrap modal dialog, using the AngularJS directives for Bootstrap.
The visibility of the div is hidden by default. This will change later on in response to a user action (e.g., clicking a button or form field). The problem I'm having is, even though the div is hidden, its contents are still occupying space in the modal body.
In other words, the height of the modal body includes the contents of the hidden div, even though it's hidden. I don't want this to happen.
Here's a contrived example of the modal template, including the div that I have set to hidden in the CSS:
<script type="text/ng-template" id="modal.tmpl.html">
<div class="modal-header">
<h3>Modal</h3>
</div>
<div class="modal-body">
<div>I'm a modal.</div>
<div class="hidden-div">
Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test <br/> Test
<br/> Test <br/> Test <br/> Test <br/>
</div>
</div>
<div class="modal-footer">
Modal footer here
</div>
</script>
It's probably easier to demonstrate what I mean with a fiddle. If you check out this fiddle, and click "Open Me", you should see what I mean.
The div with all of the "test" text is hidden, but the height of the modal body is still based off of it. How can I fix this?
Thank you for any help!
The hidden-div makes use of visibility: hidden. Although it hides the contents, but doesn't makes up for the space.
Read more about this.
To solve it, one should make use of display as below:
.hidden-div {
display: none;
}
Instead of using visibility use the display property.
https://www.w3schools.com/cssref/pr_class_display.asp
.hidden-div {
display: none;
}

Bootstrap 2 carousel second slide disappears

We are using Bootstrap 2 on a Joomla 3.2.2 site. See: http://test.stuntlist.com/west
The first slide works perfectly, but when the second slide comes in, it disappears. You can see it start to transition between the slides, but then the area where the slide should be just disappears and the content is moved up into the slide area.
I don't see any JS errors on the site. We have used the same carousel code on other sites without this issue.
Here is the carousel code:
<div class="slideshow">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<a href="/component/joomgallery/action-photos?Itemid=88"><span data-picture data-alt="">
<span data-src="/images/hero/slide01.jpg"></span>
<span data-src="/images/hero/portrait/slide01mobile.jpg" data-media="(max-width: 768px) and (orientation:portrait)"></span>
<noscript><img src="/images/hero/slide01.jpg" alt=""></noscript>
</span></a>
<div class="carousel-caption">
<div class="container">
<h4>Slide Caption Goes Here.</h4>
</div>
</div>
</div>
<div class="item">
<span data-picture data-alt="">
<span data-src="/images/hero/slide02.jpg"></span>
<span data-src="/images/hero/portrait/slide02mobile.jpg" data-media="(max-width: 768px) and (orientation:portrait)"></span>
<noscript><img src="/images/hero/slide02.jpg" alt=""></noscript>
</span>
<div class="carousel-caption">
<div class="container">
<h4>Second Caption.</h4>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
</div>
Any idea what could be causing the problem?
Thank you.
This is caused due to a conflict with Mootools, download the following plugin and apply your preferences and it'll resolve this problem:
https://extensions.joomla.org/extension/mootools-enabler-disabler
The problem is Joomla adds another DIV (We will call it JDIV) outside the Carousel container, when second/EVEN Numbered Slides are viewed some script sets the height of the JDIV equal to "0px", see my code below
<div class="col-sm-12 pharma">
<!-- this is the div which joomla is adding (JDIV) -->
<div style="margin: 0px; position: relative; overflow: hidden; height: 0px;">
<!-- this is the div which joomla is adding (JDIV) -->
<div id="myCarousel" class="carousel slide" data-ride="carousel" style="margin: -203px 0px 0px; overflow: hidden;">
<div class="carousel-inner">
....
</div>
<div class="ind-div">
<ol class="carousel-indicators">
....
</ol>
</div>
</div>
</div>
</div>
The Solution
This solution worked for me and should also work for you too.
Add a CSS class named "#myCarousel" ( ID of the carousel) and sets its margin to 0px with important,
#myCarousel{ margin:0px !important; }
Secondly add another CSS class like
.pharma>div{ height:204px !important; }
where .pharma is the class which I have used on the DIV which is outside the JDIV. The height will be different from what I have used and might have to use media queries if using responsive.
To find the height simply inspect the element and note the height of the first slide and use that height in CSS class.
I do not have a fix for you but I was able to find a few issues. The first and biggest issue being that you have inline styling that is causing the image to "disappear". The image is really just moved 572px upwards and is off the screen. Notice the two images below. The first link is the image that does work. The second link is the image that does not display.
http://tinypic.com/r/hthi4y/8
http://tinypic.com/r/2hoix35/8
Using chrome, I opened the developer console and manually changed the margin to 0px instead of -572px and it fixed the issue. I would take a look at your JS again and see what values are being applied to each image because the entire display is being rendered dynamically, I assume for mobile devices.

Selenium: Unable to click on menu item

I'm not able to click on the menu item (Create Defect...) as shown in the figure while testing my webapplication and getting below error
**org.openqa.selenium.ElementNotVisibleException: Cannot click on element**
the below code clicks on the image (hand image) as shown in the figure
driver.findElement(By.xpath("//div[#id='divToolbar']/div/table/tbody/tr/td[2]")).click();
and then the menu opens. Now I would like to click on the menu item.
I'm using below code for this
driver.findElement(By.xpath("html/body/div[10]/div/div/div/div/div/ul/li[1]")).click();
but I got the above mentioned exception
This what I have in the html:
<div class="mmenu" style="display: block; left: 49px; top: 37px;">
<div class="mmenu-content">
<div class="mmenu-border" style="width: 231px;">
<div class="mmenu-inset" style="width: 231px;">
<div class="mmenu-group first-child last-child">
<div class="mmenu-column first-child last-child">
<h3>
<ul>
<li id="liemx360120335239.81635" class="link" menuuid="emx360120335239.81635">
<span class="icon">
<span>Create Defect...</span>
</li>
<li id="liemx172704021676.66638" class="link" menuuid="emx172704021676.66638">
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
Can you please suggest?
have you tried driver.findElement(By.xpath("//span[contains(text(),'Create Defect...']")).click();
I think your problem is that the second menu is invisible, and WebDriver throws ElementNotVisibleException if he operates on a locator which is not visible.
I think you have to keep the first menu open, as the second one to be visible when you try to click it.
I use Actions class.
Try to do following :
new Actions(getWebDriver()).moveToElement(driver.findElement(By.xpath(...))).perform();
and right after try to click the second locator. If you still have problem, try to chain both commands in the same action.

how to click on a button when specific image is asscoiated with it

I am using selenium for testing my application.
In my application there are 5 buttons, each have a different image associated with it.
I want to click on button which have a specific image associated.
Currently i am using a while loop to get the node of image and then replacing this node into xpath of button to select it.
is there any way either with xpath or css to do this directly.
Providing more information-this is like submit button is there and then below this image is there. submit button and images are sibling element and need to click submit button when the next element is specific image
<div class="select">
<span class="sysTxtBtn submit xxs">
<span class="btnTagDummy">
</span>
<div class="specialRateMarking">
<img width="79" height="11" alt="Marking2" src="someimages"/>
</div>
<div class="select">
<span class="sysTxtBtn submit xxs">
<span class="btnTagDummy">
</span>
<div class="specialRateMarking">
<img width="79" height="11" alt="Marking1" src="someimages"/>
</div>
Could you include a snippet of your HTML? Below is an example of an image in a form and a few ways of locating it using Selenium, but these may not be relevant depending on your implementation:
<input id="submitForm" name="imgbtn" type="image" src="images/submit.png" />
id=submitForm
name=imgbtn
//input[#src='images/submit.png']
//input[contains(#src, 'submit.png')]
css=input[src='images/submit.png']
UPDATE:
Given the HTML:
<div class="select">
<span class="submit">
<div class="marking1"></div>
<div class="select">
<span class="submit">
<div class="marking2"></div>
You can locate the 'submit' span parent of the 'marking2' div using the following XPaths:
//div[#class='marking2']/..
//div[#class='marking2']/parent::*
//div[#class='marking2']/parent::span
UPDATE 2:
Based on the HTML now included in the question, you can locate the span with the class of submit related to the image many ways, a few examples follow:
//div[//img[#alt='Marking2']/span[contains(#class, 'select')]
//img[#alt='Marking2']/../../span
//div[img[#alt='Marking2']]/preceding-sibling::span
I hope this gives you some ideas. I'd certainly recommend XPath over CSS for locating these elements as it's much better at these sorts of relationships.