Selenium click absolute element out of view - selenium-webdriver

i have an selenium test for an Primefaces Website
I want to select a item in a combobox
when i click the combobox with selenium it creates an absolute positioned list, where i want to click an item.
But the list is positioned absolute out of the screen (because the combobox is scrollen on the bottom of the screen)
now i want to click an item
driver.findElement(element).click();
but the click gets an timeout
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
when moving the item into view with firefox (hit F12, locate element, change top-css-value to 0) the test continues correctly
any idea how to click such an element?

ok found a working solution
((JavascriptExecutor) driver).executeScript("arguments[0].click();", driver.findElement(element));

Related

Checkbox is not getting clicked properly in testproject or andriod app

i have an android app where it has 3 checkboxes in a view. All three controls are of type andriod.widget.checkbox. Along with these checkboxes there is a text content as well. Inside that text content, there is a link also. Now my aim is to click on that checkboxes. But when i click on the checkbox with testproject recording on, for one checkbox it is not getting checked though it is getting clicked and for the other two checkboxes, the link inside the checkbox is getting clicked and link is getting opened. Since it is a single view component, i could not differentiate between checkbox and the text. i have attached the testproject element explorer view and the screen view.
If you need to tap on a specific part of a mobile element (both Android or iOS), you can use the Tap element at relative point action.
You can hover the wrapper element of the element you want to tap on, double shift to capture it, and select the “Tap at relative point” action, by providing the Horizontal tap percentage and the Vertical tap percentage (notice: it starts from the top-left corner of the element) you will be able to tap on a specific point on the wrapper element.
Here you can read more about it and find an example here.

Selenium Webdriver unable to recognize richfaces dropdown value

Firepath screenshot
Link to screenshot
In my environment only browser that works is Chrome. However application also has issues and does not render richfaces dropdown unless browser is zoomed out to 80%. When zoomed out, that's the only time the browser will display the dropdown value, otherwise at 100% zoom, Chrome displays a horizontal scrollbar shows in attached. I've exhausted all my methods to try to recognize the object at runtime but it won't recognize.
Also, the HTML is completely different when selecting dropdown vs. entire page.
syntaxes used to recognize the dropdown are as follows:
driver.findElement(By.id("orderCreationForm:j_id211:productSelect")).click(); //This line to click on the dropdown pulldown tree
driver.findElement(By.xpath("//span[contains(.,'Fish Hooks')]")).click(); //This line to click on the actual dropdown item
It looks weird because most likely your CSS is overwriting some of the RichFaces styling.
As for locating the dropdown menu - it's not under the inplaceSelect parent element but under <body>. Most elements created by RichFaces have a unique class name (within the component subtree) that you can use to find the element - the dropdown parent has rich-inplace-select-width-list.

Select box automatically opens on clicking button in Chrome Android and Chrome Responsive Mode using IONIC FRAMEWORK

Short description of the problem:
I have a form in which a group of fields in repeated based on an array of objects.
There is a button which pushes an object into the array. So the user can add as many groups as he like one by one.
There is a select box as the first element of this group.
However, upon clicking the button, the select box is opened automatically after the new group appears.
Steps to reproduce:
1. Visit http://52.66.117.243/app-test/ for testing.
2. Scroll down and click on add more button.
3. The new select box for title automatically opens
Chrome in responsive mode is also able to reproduce the problem
I think the issue might be due to the click event passed on to the newly added select box since the position w.r.t screen of the button is occupied by the new select element. However, I cannot be very sure.
Interestingly, a small timeout before adding of the new elements seems to solve the problem.
If the problem is indeed the click event being propagated, can someone be kind enough to explain what is causing it, event bubbling/capturing on the ng-click or something else ?
Thank you.

In ext js panel having items and it is only shown on press of f12 button or If already in debug session on close of f12 window shows the panel

In ext js I have a form panel that will add items on tab click i.e. items related to clicked tab.Im destroying the before created items and adding new items to the panel. Items are getting added properly but panel is not displayed. When I press f12 or if im using f12 if I close the console at this time the panel is shown. on f12 window open or close the panel is shown. Why not before ? What could be the problem?
I assume that you are using a Chrome browser and pressing F12 shows/hides the developer tools. So this action resizes the viewport, forcing a refresh of the panel layout and the components become visible.
When adding/removing items from a panel a yourformpanel.doLayout() could help recalculating the layout.
Another option is to embrace the adding/removing of items with the following code:
Ext.suspendLayouts();
... // add/remove items here
Ext.resumeLayouts(true);
BTW: More details on your problem would be helpful (e.g. code snippets, ExtJS version).

Selecting a non-visible item in the dropdown for a GXT ComboBox

I am trying to test an application written using GWT 2.3.0 and GXT 2.2.5 with the Selenium 2.25 WebDriver on Java.
In the application, I have a ComboBox with a large number of options, so many that the list has a scrollbar. I need to select an item that is not visible in the list.
I run the test using the following code:
//xpath for combobox trigger
String xpathExpression = "//div[starts-with(#id,'combobox ID']/descendant::img[contains(#class,'x-form-trigger-arrow')]";
driver.findElement(By.xpath(xpathExpression)).click();
//xpath for combobox list item
xpathExpression = "//div[contains(#class,'x-combo-list-item']/descendant::div[text()='item text']";
driver.findElement(By.xpath(xpathExpression)).click();
where comboBoxID is the ID prefix I use to identify the ComboBox and item text is the text displayed in the drop-down list for the item.
If the item is visible on the page, the test runs fine. If the item is too far down on the list to be seen, I get an ElementNotVisibleException.
Is there any way for me to select the non-visible item?
Since element is not visible you cannot get a handle on it using Selenium. So one solution would be to first scroll the drop down to get to that element then do the selection.
The divs corresponding to those select values are not visible they are rendered in the DOM. Otherwise it will be rendered on the fly when you scroll. So you can execute a javascript code and set the focus (if it's already rendered not visible) to the element which you want to get or scroll the drop down (if not rendered) and select using your selectors. For example
WebDriver driver = /*driver you created*/;
if (driver instanceof JavascriptExecutor) {
JavascriptExecutor jsExec = (JavascriptExecutor)driver;
//you need to use the correct javascript here to do the scrolling or get the focus ex:
String js = "document.getElementById("elementID").scrollIntoView()";
jsExec.executeScript(js);
}
Then you will probably have to run above code under expected condition like visibilityOfElementLocated

Resources