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.
Related
I have the following test in nightwatch:
browser.click('test')
The browser.click function works in chrome but not safari. Does anyone know why it doesn't work in safari?
I have experience this as well, but in your case my best guess is that you're not passing in a correct element, like a class. Example:
browser.click('.test')
What is the 'test' that you're trying to click?
I was having the same problem and apparently the element that I was trying to click on was not in the viewport yet.
I added browser.maximizeWindow() before triggering the click event.
browser.maximizeWindow();
I also included waitForElementVisible('.test',1000) before calling click().
I have had similar issues, a solution for me was to click using Xpath. You can uses Xpath text():
browser.useXpath()
.click('XpathToElement')
also i would inject JS to the browser and try to force a click.
browser.execute(function(){
document.getElementById("nodeId").click();
},[])
However be aware that this does not always solve the issue.
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.
I want to click on the blank area of a browser. How do I do this with watir?
For example, go to google, enter some words and then click the white space/blank area so that the search suggestions box goes away.
Two possible ways to tackle this, one I've successfully done and one I haven't.
First, using watir, something I have not tried is here: How to click on specific element in canvas by its coordinates (using WebDriver)?. I haven't looked into this much but it seems like these two guys have it figured.
The thing I have tried, however, is to use something called Sikuli. Sikuli scripts can be run ontop of an existing watir-designated browser because they are purely image-recognition based. You can trigger the sikuli script to execute from within ruby and implement the canvas (blank area) click that way. Sikuli is crazy simple to use if you use the IDE to generate the macro.
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.
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.