I am using WebDriver and Asserts as modules in my acceptance testing.
Using WebDriver, I am trying to click on a label that acts as the javascript anchor for a form checkbox (the actual checkbox being hidden and a ::before font element being used to represent the checkbox as checked or not).
There is a link in this label which is located at the center of the element; the position I assume is targeted by the click() method. Due to this, I can't just click() on the element, as it will click the link instead of triggering the checkbox.
I envisioned that the solution for this problem would be to moveMouseOver(), using coordinates arguments in order to displace it to the side, then to trigger a click... but click() does not allow for a click event at the current cursor location, instead requiring a selector to be applied, thus defeating my purpose.
Is there any way to accomplish what I am attempting in the current WebDriver module in Codeception? Alternately, is there a way to accomplish this targeting of an uneven element for clicking without the process I've outlined?
Thank you for whatever help you are able to give.
I use a workaround: just making element visible via JavaScript:
$I->executeJS("$('css_selector').css({'display':'block'});");
Related
Is it possible to query which QT element currently has focus?
I'm currently working with a program and the action I want to implement requires a specific element to have focus. Instead of trying to track down through the hierarchy from the top which element I need, I'm wondering if it's possible to select the element in the UI and then query it so that I can trace it's path upwards.
If you want to know that QWidget has the focus then use the QApplication::focusWidget() method, you can also use the focusChanged signal
I apologize if the title was not clear enough. I am working on a project where a user can design a page (something like Wix). I am continuing on a project left in-complete by some developer. The sequence of action is.
The user clicks on a link which adds an element on the page (e.g. textElement, picture, slider...)
There is an edit button for each element. Clicking which opens a dialog box.
On the dialog box there are sliders and color picker drawn using Kendo-UI. Using them the user can change the style settings for the element (e.g Font-Color, BG-Color, Font Size...)
What I want now is to apply/show the changes live on that element. I have the id available for each element. I can bind each of the style selectors and apply the changes live to the text element. But that does not seem the right choice as in future we might add another style selector in the dialog box, and that would mean adding the code for binding this new selector.
What I wanted to know was that is there an alternate or preferably easy way to do this?
Regards
Share some code with the basic idea that you follow, cause it's not getting clear what you did. It sounds like you can use the MVVM framework feature to help you for that.
As you can see,I can click the first check box(PRODUCT-323),but can't click the second.After a long
trying,I find it is because the second doesn't get scrolled to view(Is it intented by tool design or a bug?).So how to scroll this popup div to ensure the second get shown?
Actually,I have tried this,but failed
((JavascriptExecutor)driver).executeScript("document.getElementById("pupop").scrollTo(0,30)");
Can you please share which version of WebDriver are you using?
If I remember correctly, Version 2.16 or so had a known issue with locators not scrolling into view. The reason being,, they were using the position co-ordinates of the center of the element to bring focus and in this case, the center is hidden from view. This was solved in later versions.
There are a couple of approaches.
1) Try to perform some action on an Element that is completely hidden from view.This will bring the element fully into view and you will be able to access it.
In this case, try to access the checkbox in 3rd or the 4th row, you will be able to bring focus there. Then access the 2nd row.
2) Do a Driver.Manage().Window.Maximize() [This is in c#]. This will also bring the element into view.
It is a good practice to avoid a window with both scroll-bars. By maximizing it you will reduce the window for such errors.
Hope this is useful.
Did u try the keyboard options?? ctrl+ down arrow through script???
Or in the worst case use tab to focus on to that checkbox.. I works in OpenScript and RFT this way.
1) To click the second checkbox: You can use the xpath to find that element. In xpath you can easily get the table row id for each checkbox which will gets incremented in their ID.
2) To scroll you can use the below code:
JavascriptExecutor js = (JavascriptExecutor) webdriver;
js.executeScript("scroll(0,0);");
I quickly tested this in Firefox, and it seems to work
<button>Go</button>
The Validator didn't choke on it, but is it a reliable way to make a button a link?
Well, anchors are not necessarily links. This is why the validator doesn't choke. External anchors contain an HREF, sure, but internal anchors simply have a name attribute that can be referenced by placing #name in the URL.
Now, whether or not you should be placing a button in a link is another issue. The DOM uses event bubbling, so technically the button should respond to the click before the link does. But I do not know if this translates the same across all browsers.
I have a small tabbed navigation setup using CSS. When hovering over the tabs the colour changes, great. However when i click a tab and it navigates to the corresponding page, i would like that tab (the active tab?) to remain highlighted, indicating the current page.
I am currently doing this by using a class (.currenttab ) and then using this class in each HTML file. I am not using:
active
Is there a way for me to use active, rather than using a class in each individual HTML file, or is what i am doing correct?
Thank you in advance.
What you are doing is correct. The :active pseudo selector means something else - the event of activating a control (ie, the time between a user presses the mouse button and releases it).
Using a class to signify the selected item is the way to go.
It's far from ideal, but if you give every page and every tab an id, you can define the highlighting in css instead of html. I ran across a full explanation while looking up the active attribute:
Highlighting Current Page With CSS
A site I designed with this technique (pages, not tabs)
Here are some more examples brainjar Demo
More from Brainjar