Selenium find by Xpath and Text - xpath

Trying to select a div by the text inside it, using WebdriveJS. Looking for a Div that contains the text, "TestIt". This seems pretty straightforward.
driver.isElementPresent(webdriver.By.xpath("//div[contains(text(),'TestIt')]")).then(function(foundIt)
{
console.log(foundIt);
}
But foundIt always equals false.
This is the div:
<div class="v-table-cell-wrapper">TestIt</div>
I actually want to be able to find the string using a variable, but I can't get the basic part to work. Any thoughts from anyone?

Should be as easy as(Assuming there is not iframe involved)
//div[.='TestIt']
Just in case if it has white spaces before or after
//div[contains(.,'TestIt')]

Well, I learned something very good today. I was using Phantom to test, but the problem is of course that you can't see what's going on. I had started on Chrome. I moved back to Chrome I realized that I was no longer getting as far as I was before in my script, hence the inability to find the element. I feel a bit stupid, but live and learn. Thanks for replying, guys.

Related

How to make a website menu exactly like the one right here on stackoverflow on ASP.NET MVC 4?

I started using asp.net MVC 4 and I don't quite understand how could I accomplish simple tasks like making a simple navigation menu for my website, I would like it to be just like the one here on stackoverflow where the images change on mouse over and also link to their corresponding pages.
what used to be a few minutes of work with HTML (in Dreamweaver for example) now takes much much more time and thought (at least for me).
Investigating about the 3 elements I've mentioned got me here:
How to show an image- even that is not easy, I have looked everywhere for something that looks like an ideal solution but couldn't find any! even here on stackoverflow, some solutions are involving writing long lines of code in the name of "Helpers", and I could dig into it but there are so many different solutions, and I wouldn't know which one is right.. why can't there be just one standardized solution?
How to link an image- also an issue, that i understand that I need to set the controller in the parameters list but again I ran into and issue that I might have found the solution for I just need to test it, I have read that I could have different methods inside of one controller and in this way I will not have to have one controller for each link. I will try that, better solutions are welcomed.
How to swap an image on mouse over- also looks crazy for me, I have found one solution where there are long lines of code for this here: http://www.codeproject.com/Tips/329596/MVC-3-Helper-for-Hover-Images
I am kind of disappointed that just for putting up the logo image and linking it I spend days! I do have background in .net c# HTML+CSS etc'.. so I am asking myself (and you guys) why does it have to be so unclear and not friendly?
Come on.. what am I missing? is there any library of helpers everybody is using or something like that?
I am still in the process of learning MVC 4 and I know I'll get it but I would've expected accomplishing these kind of simple tasks a lot faster.
also, in Microsoft examples, I have never found an example where they put a logo or a menu image, it is always plain text! so annoying and frustrating...
I will very much appreciate any help..
Thanks a lot!
Roy.
Start with http://www.asp.net/mvc/mvc3 and understand what are the paradigms of it and what is the differance between webform and mvc systesm.
Basically you need to understand how the masterpages are evolved in mvc or what is the replacement of master pages in mvc.
This is clue to what you want to achieve.
Now if you want to put the Image button in which if you hover and color will change then you need to do following steps.
Create a button first e.g
Html.ActionLink("YourButtonName", "Index", null, new
{#class="hoverButton" })
Now you need to create two classes in your css file with name hoverButton which contains property to show image and hoverButton:hover show image when you hover over the link. Like following.
hoverButton {
margin-bottom: 10px;
width: 160px;
height:160px;
display:block;
background:transparent url('Button.png') center top no-repeat;
}
.hoverButton:hover {
background-image: url('hoverButton.png');
}
This way when you hover over to button it will display different image in mvc view menu item.
Hope you understand the concept and it helps.

UTF-8 characters acting weird

Okay my problem is that a couple of my special symbols show up as a little box, look here:
http://i.imgur.com/9mPL4.png
The symbol number is: \e8a1
The way it should look, and odly has no problem on this site is like this:
http://i.imgur.com/rZOUN.png
I have forced upon UTF-8 via .htacces and no luck too. I've been trying for some time now.
I fail, this entire time the answer was in front of my face :P .icon-logo-entypo:before Entypo being the font :) downloaded and it's working now!

Issues with WIDTH and HEIGHT percentages in a DIV via CSS (firefox doesn't work)

My brain is overflow about this issue, so let me share my frustration in order to look for someone having the same experience and, luckily, finding a solution.
The thing is the following:
http://jsfiddle.net/w4d2E/
In chrome, percentages work fine, but when trying the same in Firefox (latest version) the content div is not expanding horizontally and vertically anymore.
I've analyzed every similar question over here, but I can't find any valid answer.
Thanks in advance
P.S.: I've tried to use block display instead of the 'box' one in the 'content' layer, but still having the same behavior.
You're using XUL box layout. I suggest not doing that. -moz-box is NOT CSS flexbox layout, as you seem to think.
The problem here is display: -moz-box for body. If you remove it everything works fine. It appears to be a bug, so I suggest filing a report in the bug tracker.

How did they do that? Keystroke Text Animation

I found this website, and I can't figure out how they made the text animation on top work. It looks like jquery, but I can't figure out the code. Does anyone know what they used to make the keystrokes appear on this website?
http://nine2011.9elements.com/
Have a look at this:
http://www.burnmind.com/tutorials/typing/
The tutorial:
http://www.burnmind.com/howto/how-to-create-a-typing-effect-an-eraser-effect-and-a-blinking-cursor-using-jquery
That seems like exactly what you were looking for.
Looks like they fill the 'canvas' section by writing one div (each with one letter) at a time, and deleting them one at a time, using a Timer (maybe 250ms?) for each action. All possible using JavaScript document manipulation; easier with jQuery though.
I can't find a really good tutorial on how to do it with vanilla JavaScript, and there's always cross-browser quirks, so you'll just have to play around if you want to do a similar effect.

jqGrid "Loading..." overlay showing "undefined" though grid is working

I have a jqGrid that's working 100% except that it keeps displaying "undefined" in the "Loading..." overlay. I can't really figure it out. It seems like I should only get the "undefined" message if something isn't set right and the grid would cease to work. But that's not the case. scratches head
I'm not really sure a code sample would help here, but if anyone would like to see a certain part of my code let me know and I'll included.
Has anyone else come across this issue before? I'm probably missing something so simple and small that I can't see it. So my apologies in advance if this is a no-brainer
Thanks for your help.
That text comes from $.jgrid.defaults.loadtext. So either:
You have an old grid.locale-en.js which doesn't specify it, or
You overwrite it somewhere.
In addition, I've found that the <script> tag that defines grid.locale-whatever must appear before the <script> tag that loads jqgrid.
Doesn't make sense to me.

Resources