Selenium Webdriver unable to recognize richfaces dropdown value - selenium-webdriver

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.

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.

Office UI Fabric Panel scrolling to first input

I have a problem with Office UI Fabric's Panel (well, also Modal). I'm rendering them with multiple input fields to provide data for my app. Due to the number of fields the controls are rendered with a scroll bar. After scrolling down and clicking outside of the input, the focus is being set on the first textfield/dropdown in the container panel what causes the whole thing to be scrolled to the top. Is there a way to prevent setting the focus/scrolling to the first element when clicking outside of the input?
This was indeed a bug and has been resolved already. Tested it in the version 5.56.0.

Scroll down on the terms and condition Textbox and click on Agree selenium

I am working on Protractor tests. Recently my web page changed where the terms and conditions are inside a textbox. Button Submit works only when the user scrolls through the textbox and clicks on Agree button. I tried the following option to scroll down but it is not scrolling down. Any help is greatly appreciated.
var scrollbar = element(by.id('terms-conditions'));
var checkbox = element(by.id('checkbox'));
scrollbar.click()
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);')
checkbox.click();
I followed the below link too but no luck.
Protractor: Scroll down
The second js execute statement you are using contains Window.scrollTo which references an open window in a browser. and using it only scrolls the complete window but not the pop-ups that appear inside a browser window
Refer here for documentation on Window.scrollTo
Normally terms and conditions shows up in a pop-up or may be a div and hence Window.scrollTo doesn't work
there are two ways you can do it
SOLUTION 1: use Jquery scrollTop() to scroll inside a specific webElement
Step 1: Identify the exact div that holds your terms of Service scroll bar
Step 2: Refine your js statement by trying directly in Chrome console
$('.modal-body').scrollTop() -> This returns the current position of scroll
$('.modal-body').scrollTop(10000) -> This sets the value of top position
Step 3: Incorporate this in your protractor script
browser.executeScript('$('.modal-body').scrollTop(10000)');
You can professionalize this by passing the element & scroll amount as arguments. Refer here
SOLUTION 2; The best way I see to submit a pop-up is not to deal with interface but to deal with the 'form' element behind it. Similar to how we deal with file uploads.No fuss & effective
May be try something like this, by making button visible first and then submit form
browser.executeScript is an asynchronous call, so you will need to put it into the controlFlow so that it will complete before clicking the checkbox:
scrollbar.click();
browser.controlFlow().execute(function() {
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);');
});
checkbox.click();

Is it possible to have class or ids on the grid drop down filter?

Can you have HTML ids or classes for the drop down filter/sort widget in extjs Grids?
What I mean is this component :
It's needed for test automation purposes. However we can probably live with it if its not possible, using some fancy CSS selectors instead.
Grid column menu can be quite tricky to test. The main problem that I see is that its html markup does not exist before you click on the column menu button (down arrow). When you click it the main menu with sort, columns and optionally filters is rendered (html markup is created), however, columns submenu html still does not exist. It is created when you move mouse over Columns item of main menu when the submenu is rendered and shown.
From that point on it exists for all columns because only one menu is use for all.
Thus, for testing, you would either need to simulate mouse clicks/moves or manually render the menu/submenu.
You can find out CSS classes involved (after the menu is rendered) by using developer tools to inspect the html markup.

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