How to scroll a swf app using Selenium webdriver - firefox

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.

Related

Alt-click select word behaviour differs to native textarea

I'm using a pretty bog-standard installation of CKEditor 5, and have noticed that alt-clicking on a Mac is acting differently in ckeditor to a basic textarea.
Textarea:
Right click a word, and it will be selected - 100% of the time.
CKEditor:
Right click a word - it seems a little unpredictable - the only way I can make it work every time is if I place the cursor within the word everytime.
This issue was raised as a user pointed out that the browser spellcheck only works on the second attempt, so not ideal.
I created a video showing the behaviour on the ckeditor examples website - with a textarea just thrown in using devtools - https://www.youtube.com/watch?v=k0pDCdbNZpc
Has anyone come across this before and found a solution at all? Thanks!
edit: confirmed as an issue on GitHub https://github.com/ckeditor/ckeditor5/issues/11898

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.

Selenium fails to click a checkbox under a fixed footer

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.

How to handle pop up/lookup windows in selenium

I am doing some web automation using Selenium RC. Am new to Selenium RC and am facing problems (may be learning curve) while doing automation. I am using java with Eclipse IDE to code selenium RC.
Scenario: I have a screen with a link. while clicking, it will open a lookup window which contains lot of names (grid). Now I have to select a value from grid by directly clicking any row/record. Or I can use search option and select the record. The problems are
my recorded script is NOT responding to pop-up windows.
Is there any command for "double-click" in selenium.
#rs79 - It didn't work for me. Here is my code:
selenium.click("link=eName"); //click the link to open the lookup window
//lookup window
selenium.focus("Associate"); <br>
selenium.waitForPopUp("Associat", "20000");
selenium.selectWindow("Associat");
selenium.type("id=SearchTextBox", "xyz"); //Enter the text in search field of lookup
selenium.click("id=SearchButton"); // click search button on lookup window <br>
Please correct me if I am wrong. Appreciated if anyone give me more suggestions.
Without access to your DOM, I would recommend recording using the IDE, and adapting the right context from the recorded actions into RC. The IDE does a decent job of capturing the context for popups and modals.
After the capture, here are some gotchas:
For iFrames, change the captured frame id to a more generic (css) locator
Be wary about the difference between selectWindow() and selectFrame()
If its a popup not an popup window then you can try the firebug to locate the element or record you want.
Now copy its xpath and use it in your code.
Same problem I have faced and solved by this method as xpath from fire bug is detailed and locates the proper window.
After coping xpath please verify the path has // at starting.
Thanks
This will help to handle salesforce lookups
Iterator it = windows.iterator();
String parentwindow =(String) it.next();
String childWindow =(String) it.next();
// Switch to parent window
driver.switchTo().window(childWindow);
MiscUtils.pauseForElementToBePresent(3000L);
driver.switchTo().frame("your frame NAME/ID");
MiscUtils.pauseForElementToBePresent(3000L);
// your step to perform on child page.
driver.findElement(By.linkText("123Test")).click();
MiscUtils.pauseForElementToBePresent(3000L);
//if popup is getting close automatically switch to parent window otherwise use "driver.quit();" to close popup
driver.switchTo().window(parentwindow);
driver.switchTo().defaultContent();

Where is API call to do "lights out mode" in honeycomb?

I am working on a game and would like to have the full screen to itself.
Did anyone found a way to make the app go full screen on Android Honeycomb preview emulator?
Lights out mode has changed in the full 3.0 SDK. You can now enter lights out mode as follows:
View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
You can also set a listener on the view to be notified on changes to the system bar's visibility.
In prior versions of Android you can set the application to a full screen mode using this line in the manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen".
I can't say for sure that works in 2.3, since I haven't done anything with 2.3 yet.
Secondly, I'm not too familiar with the term "lights out mode" but you can adjust the screen brightness using the WindowManager.LayoutParams class and the screenBrightness field.
Two things I can add:
My ListActivity hides the status bar, but when it pops up a progress dialog the status bar shows for as long as the progress dialog is displayed. The following reduced it to a brief flash, and applies to all dialogs done via "showDialog". I can't get rid of it entirely yet.
protected void onPrepareDialog (int id, Dialog dialog) {
View main_layout = dialog.findViewById(android.R.id.content).getRootView();
main_layout.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
}
CAVEAT: "onPrepareDialog" is deprecated...
As shown in the snippet above, you can get the root view's ID without defining an explicit ID in the parent layout in the xml layout file, which makes this a one-file edit.

Resources