Selenium fails to click a checkbox under a fixed footer - firefox

I'm automating tests using Selenium on Firefox, and everything was working ok until I needed to check checkboxes that are not visible due to a footer that is fixed to the bottom of the page.
It's a long list of disclaimers that are necessary to be checked in order to continue.
The first two are below this footer, the rest forces a scroll down, and are checked correctly.
My question is:
1) Is there a way to check the first two even thought they are below the footer?
2) Is there a way to make Selenium scroll down using a command?
3) Is there a way to make Selenium to open a new Firefox window maximized? (I believe that if this is possible, all checkboxes will be visible on load)
Thank you!
PS: This is my second post, if I'm missing some information please let me know and I'll edit it.
EDIT:
Firefox version: 23.0.1
Webdriver version: 2.35
Unfortunately, i have only configured my webdriver for Firefox (not on chrome at the moment)

You don't have to scroll the page as long as you are finding the Element with correct selectors (e.g. xpath, css etc.), so something like driver.findElement(By.xpath("xpath")); should remove the need to scroll the page. As for opening the page in full screen use the following
driver.manage().window().maximize();

If your web page needs to be scrolled down to interact with element, first you'll have to bring that element into view. Using Ruby, this can be achieved by following:
element.location_once_scrolled_into_view
and then interact with element.

You can use javascript executor to scroll the page. I've found that Selenium will click objects that are "visible" but hidden behind something else on the page.
JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");

I use the capability:
capabilities.setCapability("elementScrollBehavior", 1); // 0- from Top,
// 1 - from bottom
When I start the driver, I set the capability.

Related

mouse over and click in Capybara

Got stuck in capybara coding. appreciate any help on this.
I need to mouseover on source element to click on the target element link.
Not finding a way to get it. need to use this in chrome browser only.
Tried the code below
source=ses.find('#source-link')
ses.driver.action.move_to(source).perform
ses.find('#child-link').click
If what you're trying to do is hover over #source-link and then click `#child-link' it should just be
sess.find('#source-link').hover
sess.find('#child-link').click
If that doesn't work for you then we need to know exactly what events are triggering the behavior you expect.

Watir - clicking on element works diffrent than manualy

I wrote test in watir, and one of line doesn't work correctly:
$browser.element(:css => '#sub-15079 > div.ardbnServerInformation').click
When I click manualy on this element, browser opens new tab and everything is fine. But when watir clicks on this element, browser opens new window (instead tab) and data in window doesn't load. How to fix this difference in behaviour?
Sounds like maybe some countermeasures are being used to block the scraping efforts...some kind of javascript thing...
A surefire way to overcome these types of things is to a visual-based automation tool something like Sikuli (sikuli.org) to visually identify a link and click it. It actually uses optical recognition rather than the DOM to identify links and click them.
A more haphazard way to go about this would be to use something like cliclick to click based on screen coordinates, but this is not a very good solution in my opinion.

How to scroll a swf app using Selenium webdriver

I am using:
Eclipse Version: Luna Service Release 1 (4.4.1) - JAVA
Selenium Webdriver version 2.44.0
Sikuli (whichever version was with the 1.0.2 api)
The Situation:
I am working with a swf app. Content is a booklet that changes content every so often. The booklet has buttons that allow you to page/zoom. I have managed to automate the process of getting to the booklet, as well as paging and zooming. But I wish to be able to scroll up/down a page once being zoomed in on a page.
While 'normally' using the booklet you can scroll either by dragging with the mouse, or by using Up/Down Arrow keys or Page Up/Down.
I have tried using the following:
Actions scrolld = new Actions(driver);
scrolld.moveByOffset(0,-100).click();//this is to make sure the booklet is selected
scrolld.keyDown(Keys.ARROW_DOWN);
scrolld.perform();
^this piece does nothing - I have added multiple send key commands, and I have made use of eg.: Thread.sleep(100) in between the commands.
JavascriptExecutor jse = (JavascriptExecutor)driver;
for(int second = 0;; second++)
{
if(second >= 3)
{
break;
}
jse.executeScript("window.scrollBy(0,800)", "");
System.out.println("Scrolling...");//this prints "Scrolling..." each time a scroll is done.
Thread.sleep(3000);
}
^I found and tried this piece - it scrolls on websites, but it doesn't scroll in the swf app - even after I've tried shifting focus to the element/window (even though the swf doesn't generate a new window). I wish to have it scroll incrementally, though have also tried jse.executeScript("window.scrollTo(0,document.body.scrollHeight);"); which also does nothing.
I have also tried making use of (this is Sikuli in Eclipse) -
Actions build = new Actions(driver);
build.moveByOffset(0,-100).
clickAndHold().
moveByOffset(0, -200).
release().moveByOffset(0,200);//this was all typed in single line - this line-line view is for legibility.
^but apparently clickAndHold + moveByOffset don't work together at the moment (it's a bug or something - I can't find the link to where someone said so now).
Any and all suggestions welcome - please take note I am relatively new in this field and not as advanced as I would like to be... yet!
Maybe you can look with sikuli if the scrollbar is present, and if yes. Then you click on the scrollbar and hold the mouse down. Then move the mouse up/down.

Gecko WebBrowser, getting the url from a selected hyperlink

This is a real 2%er but here goes, I have created a winform in VS2010 with Gecko 2.0.1-0.10 (latest release) webbrowser control, I am using a touch screen to navigate. Sometimes when clicking a hyperlink it will select text rather than navigate, on the DomMouseUp event I want to check to see if there is selected text, if so I want to see if it is a hyperlink and if it is, where that hyperlink goes to. I had a mess around with GeckoSelection but nothing looked obvious. I am looking for a way to see if what is selected within the web browser is a hyperlink, any thoughts?
I've worked it out : for anyone interested in such things, use DomFocus on the gecko control:
m_strInnerHtml = geckSel.ActiveElement.Parent.InnerHtml.ToString();
That will give you the innerhtml of the selected item, from here you can extract the href tag and get the url, navigate to it, hey presto :)
Update: An even better solution is to use (in DomFocus again)
m_strInnerHtml = geckoWebBrowser.Document.ActiveElement.GetAttribute("href");
This will return the actual hyperlink address, one thing to watch out for however is if you're on google for example and select the "Advertising" hyperlink at the bottom of the page, it may return "/advertisingpage/" which must be appended to the original url. Clicking a hyperlink away from google will return the full address however.
Very good behavior gives this call:
m_strInnerHtml = geckoWebBrowser1.Url.AbsoluteUri()

Manipulate Html from Firefox Extension

I am creating a Firefox extension that is somewhat similar to Firebug. There is a panel (or vbox) at the bottom of the browser that allows users to specify colors to certain Html elements. When they click the OK button, I would like these colors to get updated on the current web page.
I have my JavaScript working when I click the button (i am just throwing an alert), however when I change that JavaScript to change the css or styles of an element (by either using document.getElementById or jquery), nothing changes.
Is there something with Firefox extensions that I am missing? Any help is appreciated.
Let me know if you have any questions. Thanks
https://developer.mozilla.org/en/Extension_Frequently_Asked_Questions#Accessing_the_document_of_a_webpage_doesn%27t_work
You want content.document.getElementById() and similarly for every other construct you use.

Resources