Cannot locate link css or xpath - ruby

I started to learn ruby (rspec , rubymine).
I want to do simple click action but I have a problem.
Id and name does not exist so, I should use xpath or css.
I tried #click on contact link:
driver.find_element(:css, 'html>body>footer>div>div>section:nth-child(3)>a:nth-child(1)').click + ' :: absolute path'
xpath showed me:
/x:html/x:body/x:footer/x:div/x:div/x:section[3]/x:a[1]
link is:
Contact
and this is FIRST link in:
section class="link-block link-collection col-xs-12 col-sm-4 col-md-2"
and section class is placed in div: class="row"
and this is here: <footer class="footer" role="info">
and this is inside: <body data-touch="false" class="abc">
Can anybody help me?

I used now Css but...it clicks on another links and css is the same! strange..hm
css: .footer .container .row .link-block h4 + a
so, how can I do this with xpath?;/
I used
#driver.find_element(:xpath, '//html/body/footer/div/div/section[3]/a[1]').click and it works:) but..what if sth will be changed on page?

Related

IE8 don't show <figure> Tag although html5shiv

my IE8 doesn't show images inner the figure tag.
TYPO3 Installation 6.1.x
DOCTYPE HTML5
css styled content (latest)
Frontend: Text & Image will shown as
<div class="csc-textpic-imagewrap">
<div class="csc-textpic-center-outer">
<div class="csc-textpic-center-inner">
<figure class="csc-textpic-image csc-textpic-last">
<img height="308" width="828" alt="" src="fileadmin/media/image.JPG">
</figure>
</div>
</div>
</div>
I 've included HTML5shiv Script - nothing happens .. then I tries to unwrap the figure element with jQuery - nothing happens
Has anyone an idea how I can show my image wrapped with
it was a responsive big
img {
max-width: auto;
width: 100%;
/* and for IE 8 */
width: auto\9;
}
That's it Damn.!
I had the same problem:
tt_content.image.20.rendering.singleNoCaption.singleStdWrap.wrap.override >
tt_content.image.20.rendering.noCaption.singleStdWrap.wrap.override >
Or instead of deleting it, replace it with whatever html you like.
just set this in config typoscript
doctype = html5

CSS selector for other tags other than div and span?

I have been using css selectors as div and span till now while using Selenium WebDrivers with Ruby for testing.
However I have some dd and xmlns:dd attributes as well. Is it possible to have a css selector for this as well.
Html Code:
<div class="class1 class2 class3 class4" style="padding: 4px;" id="_c04a6325-5316-4177-980f-38484eb27730">
<span class="class5" style="font-weight: bold; text-decoration: underline;">Month</span>
<div class="class6" dd:contenttype="Month" dd:referenceuuid="1446A201-FD91-4A82-B645- 306DC948DC48" id="_3d510b04-8a5a-4bf9-bc7a-8efd55f9ca48">
<div xmlns:dd="Week" class="class7 class8" dd:entityid="1457893" dd:contenttype="Monday" id="_7480bbe4-bbf0-4a54-8994-ae773b418470">
Breakfast
</div>
</div>
</span>
</div>
What I presently do:
$driver.find_elements(:css, 'div.class7.class8')
What I want to do:
Something like this to use the data in dd:contenttype and/or xmlns:dd to find an element
$driver.find_elements(:css, 'div.dd:contenttype="Monday"') OR
$driver.find_elements(:css, 'div.xmlns:dd="Week"')
Is the possible to find and element using dd:contenttype and/or xmlns:dd??
use $driver.find_elements(:css, 'div[dd\\:contenttype="Monday"]')
for more information you can take a look on http://sauceio.com/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/
Try this way:
$driver.find_elements(:xpath, "//div[#class = 'class6 class7' and #dd:contenttype = 'Monday'")
The above should work.

Href Links not working in Firefox

Please help! I have tried using Firebug to see why my href's are not click-able but I can't figure it out. I don't use tables. The site is http://spiritfestcorpus.com/
The big circular image is wrapped in a href
I'd really appreciate any suggestions.
Here is the code from line 357 if you VIEW SOURCE in Firefox
<div id="slideshow_wrapper" )">
<div id="frame"></div>
<div id="slideshow_container">
<div id="slideshow">
<a style="z-index:9999999; position: absolute;" id="cdImage1" href="concertsbuy.aspx?eventId=53"><img id="Repeater1_ctl00_cdImage" src="images/slideshow/home/albums/2012/SPIRIT_Fest_Corpus/LMG_DC12Circle.png" style="border-width:0px;" /></a>
with position: absolute you must specify width and height. And if you are going to specify width and height on an a tag, you need to use display: block

WatiN SelectList or DIV Click from Google Adwords Keywords Page

I have tried everything but no luck. I am using Watin and C# .NET
What I am doing is going to:
https ://adwords.google.com/o/Targeting/Explorer?__u=1000000000&__c=1000000000&ideaRequestType=KEYWORD_IDEAS#search.none
Note: There's no space between https and ://, but I had to add it because of a markdown problem
Entering the captcha manually (typing the text from Watin).
After you search for keywords, you will see that in the bottom of the page you have a Next and a Previous button.
I would like from WatiN to go to page 2, 3,...
It sounds simple, click on the div (with id gwt-debug-aw-paging-next ) and it will go to next page, but it does not happen.
I tried FireEvent, click, KeyDown, everything ... but it's not working.
I also tried to select 100 results from the Selectlist, but again, it does not work.
I tried it in all ways:
browser.DomContainer.SelectList("gwt-debug-aw-paging-list-box").Option("100").Select();
Nothing seems to work when talking about the buttons from the bottom right of the page.
I managed to "simulate" the click on Broad or Exact results, but not with the bottom buttons.
Any suggestions?
Edit 1:
I uploaded an image so you can see exactly the button I am talking about:
Click here to view it larger.
<div id="gwt-debug-aw-paging-next" class="goog-button-base goog-inline-block goog-button aw-btn aw-pagination-button" tabindex="0" title="Next page">
<input type="text" tabindex="-1" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;">
<div class="goog-button-base-outer-box goog-inline-block">
<div class="goog-button-base-inner-box goog-inline-block">
<div class="goog-button-base-pos">
<div class="goog-button-base-top-shadow"> </div>
<div class="goog-button-base-content">
<span id="gwt-debug-aw-paging-next-content" class="aw-pagination-next"> </span>
</div>
</div>
</div>
</div>
Please paste the markup of the element you would like to click, including a parent element or two.
This will help in suggesting solutions.
Thanks.
So the following does not work?
using(IE ie = new IE("your-page's-url"))
{
// ... any steps needed to bring up the page in question ...
ie.Element("gwt-debug-aw-paging-next").Click();
}
If not, maybe try clicking on the span gwt-debug-aw-paging-next-content.
I managed to solve the problem. Another programmer gave me this tip, so the credits go to him.
The idea is that there are more spans with the same ID in google adwords (strange, I know), so what we need to do is click on every span, not only at the first span.
Here is the final code that needs to be added:
var pagination = browser.Spans.Where(e =>
e.IdOrName == "gwt-debug-aw-paging-next-content").ToList();
foreach (var item in pagination)
item.Click();

loading div content from external with jQuery.load into own div

Let's say that I have two html pages that are identically designed, but have different content. I have the same div with the same id on both pages. How do I use jQuery.load (or what do I use) so that the div#conent does not get added into the div#content of the first page.
I've tried this:
$(document).ready(function(){
$("a#linkHome").click(function(){$("div#content").load('index.htm #content');});
$("a#linkPage2").click(function(){$("div#content").load('page2.htm #content');});
});
... but it ends up adding another div to the already existing div!
<div id="content">
<div id="content">
Blah Blah Blah
<div id="content">
</div>
Try with:
$(document).ready(function(){
$("a#linkHome").click(function(){$("div#content").load('index.htm #content *');});
$("a#linkPage2").click(function(){$("div#content").load('page2.htm #content *');});
});
in this way you get all elements inside the div#content but not the div itself.
Or you can try the opposite approach. Just add a wrapper div into your target page.

Resources