Finding Elements in a Redrawn DOM - java

We have a website which has a wijmo grid in it. I am attempting to test this website. In IE the grid is drawn, yet when I go into the "Developer Tools", the grid is not actually there. This makes running Selenium tests very difficult as Selenium cannot find it either.
Has anyone run into this before? If so, how do I successfully run my tests?

The grid will be part of the DOM and you should be able to select it successfully with the correct path using Selenium.
I believe it is the tools that are misleading and are simply not updating when the DOM changes.
I would try checking another browser, for example Google Chrome (F12 in Windows). In my experience the IE Developer Tools are not as powerful or feature rich as the Chrome tools. The Chrome tools do update the DOM when elements are manipulated.

It looks like it is working now. The Developer had a pre-loader which was causing the problem. Once that was disabled it is now able to find the elements.

Related

I am trying to access secure website where right button click is disabled. by using selenium Xpath cannot click on elements

The website which for which I am trying to do automation is a secure website where some functions like right clicking have been disabled. I am using the exact xpath for the login input field but it is not working. My Xpath is as follows:
driver.findElement(By.xpath("//input[contains(#class,'input')]")).sendKeys("Aa12");
SeeTest provides a way for opening the developer tools even in such cases.
They also have different versions of chrome in which you can try your scenario.
Their documentation might help you more on this.

Selenium Webdriver Modal not appearing when automated

I am writing automation code using Selenium Webdriver Java against an application for Point of Sales systems.
When the application opens up at first there is a modal dialog which appears for the user to select an item on. This modal appears no problem when testing manually. Until just recently it also appeared when running automation.
It no longer does. The behavior is different between manual and automated runs.
I'm running against Chrome and I've set the "disable-popup-blocking" option for the Chrome driver, but it doesn't seem to be helping.
The developers also have no idea what might have changed. I am at a loss and just looking for any thoughts about where to look for clues.
Thanks.
Let me try to address your query:
The behavior is different between manual and automated runs is factually incorrect statement until & unless you are controlling the WebDriver instance with arguments.
As you mentioned there is a modal dialog which significantly means that the code for the dialog is present in the DOM. Maybe it's within​ a frame which we have to find out.
"disable-popup-blocking" option for the Chrome - The purpose of this option have nothing to do with element present in the HTML DOM.
Amidst all the confusion, the best solution may be to take help of Selenium Builder & put an end to all guesses.
Let me know if this answers your question.

Jsoup: Getting a link that doesn't show in the HTML

I am working on a little app for myself. I am trying to get a list of links from a site. The site is for example: http://kinox.to/Stream/Prison_Break.html
If you hover over the big window in the middle that says kinox.to best online, it show the link that I want in the bottom left. The problem is if I look at the html file I can't find the link anywhere. I guess it has to do something with the site using JavaScript or Ajax.
Is it possible to somehow get the link using JSoup or are there any other Java libraries that could help me?
I did not look closely into the page you try to load, but here is what I think the problem may be: The link is loaded/generated dynamically via JavaScript. Jsoup does not run JavaScript, so therefore you can't find the link in the html.
Two possible solutions:
1) Use something like selenium webdriver to access the content. The Java bindings allow to remote control a real browser which should have no problems loading the page and running all scripts within. Solution 1 is simple to program, but runs slowly. It may depend on an extern browser program which must be installed on the machine. An alternative to webdriver is the JavaFx webkit engine in case you are on java 8.
2) Analyse the traffic and the JavaScript on the page and find out where the link comes from. This may take a bit of time to find out, but when you succeed you can use Jsoup to get all the data you need. This solution should run much faster than solution 1.
One solution and probably the easiest would be to use Selenium:
WebDriver driver = new FirefoxDriver();
driver.get("http://kinox.to/Stream/Prison_Break.html");
String mylink = driver.findElement(By.cssSelector("#AjaxStream > a")).getText();

Selenium is breaking my page in IE11 when I set text

I made some Automation tests with Selenium working on chrome, but now when I tried them in IE11 I got this weird behaviour: I land in a Page with a Search Box and a Search Button, pretty standard, and when I either set(" ") or sendKeys(" ") to an input textbox, the page "moves" to the left as is it had broken, imagine the page in the center of the screen and suddenly the left margin would dissapear and the page would stretch to the left... Does anybody know what I'm talking about?
Any help please?
BTW I also tried doing some actions in other elements and they won't break the page, also clicking the textbox won't do the trick, it happens when I put text in it
Well, "sendKeys" is likely what we call a "native event" and so it depends highly on the implementation of the binary driver for IE. For example, Selenium only officially supports native events on Firefox up to version 31.0.6 and not versions 32+. IE11 is pretty new and also comes in different versions (since it auto-updates). So, if you need to do a sendKeys that is non-native (which is usually not necessary) then you can probably code one using a JavascriptExecutor object. Let us know if that works for you.
-- addendum --
The Selenium team would tell you that they didn't want to include the javascriptExecutor funtionality in Selenium, but it is scenarios like this where the executor capability shows its true value.

How to code an automated bot that can browse and do operations on a webpage. JAVA

need to code a bot that needs to do the following:
Go to a jsp page and search for something by:
writing something on a search box
clicking the search button(submit button)
clicking one of the the resulting buttons/links(same jsp page
with different output)
get the entire html of the new page(same jsp page with different
output)
The 4th one can be done with screen scraping and I do not think I need help with it. But I need some guidance to do the options from 1 to 3. Any links or just some keyword that will help me Google to learn about it will be appreciated. I plan to do this with java.
My suggestion is to use Selenium (http://docs.seleniumhq.org/download/).
Install Selenium IDE in your firefox, and it can record what you do on a website, store it into a script and reply it.
This video (http://www.youtube.com/watch?v=gsHyDIyA3dg) is gonna be helpful if you are a beginner.
And if you want to do it in Java, its easy, just export the scripts in Selenium IDE to JUnit Webdriver code.
Of course you can use Selenium Java webdriver in Java to write your program to operate on website directly.
Selenium automates browsers. That's it. What you do with that power is entirely up to you.
The above steps can be done by using selenium(which is a testing tool in java)
Even points 1 to 3 are screenscraping - you're figuring out (using either manual or automated means) what's there in the page and performing actions on them. You could try exploring the Apache HTTP Client for an easy way to run HTTP commands and get responses.
I hope you're doing this for legitimate means - screenscraping is almost always frowned upon if done without permission.

Categories