Selenium record and play back a css element - css

When i try to playback a recorded script, in which there is a click on css drop down like thing and select an option from it, i got the following error:
"Element not found".
Here there is nothing like loading so that it takes some time and element is not visible. It's just a plain web page.
Please help me in resolving this issue and go on with the recorded script.

Try invoking a mouseOver command on the underlying element, that should give the dropdown menu a hint to appear and the element you're missing will be visible.

Related

A-frame inspector disappears

When using the A-frame inspector, it will appear when use CTL+ALT+I - however the side panel on the right has disappeared. When I select the a-scene that appears. However when I select an object to move around the scene the whole inspector disappears and it will not come back unless I refresh the page.
I opened the a-frame inspector and selected an object to move. I expected the inspector panels (left and right) to appear and show me the scale, position etc
Did you happen to be clicking on an object with aframe-physics-system component? Not sure if you're getting the same error, but it's likely that the Aframe inspector crashed. This has happened to me when I was trying to select a physics object in the scene. When I open the browser console logs, it says something about a React error
index.js:303 Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
that links to:
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
Screenshot of the Aframe inspector error I'm getting
Example physics example that breaks inspector: https://c-frame.github.io/aframe-physics-system/examples/ammo/sandbox.html

Multiple cursors appearing in each cell in Jupyter notebook

I'm getting a separate cursor for each cell. After execution of one cell, the cursor does not move to the other and when I click on the next cell the cursor appears in previous and present both.
CLICK TO SEE THE IMAGE
Was researching this problem and found an answer;
the answer happens to be from your post as well!
Solution 1: Change the default browser (link)
Solution 2: Reset the browser to factory settings (link)

Accessing elements inside iFrame documents in Selenium WebDriver

I am trying to automate a scenario where I would need to access elements inside an iFrame and continue my testing.
My current problem is that, I am able to switch to the iframe successfully, but I am unable to access contents inside the frame.
The contents inside the iframe are Shadow DOM contents and are inside a document.
The HTML code looks like this::(Please see attachedHTML)
I have tried the below and get
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element
By accessing the shadow root
driver.switchTo().frame("iframe_id");
WebElement root1 = driver.findElement(By.className("class_abs"));
WebElement shadowRoot1 = expandRootElement(root1);
Here webdriver is unable to find element by classname.
2.By using Javascript executor
driver.switchTo().frame("iframe_id");
JavascriptExecutor js=(JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", driver.findElement(By.xpath("button_xpath")));
Here webdriver is unable to access the Xpath.
3.
Using normal Xpath after switching to IFrame.
I would like to know if I need to access the contents of the document inside iFrame first to access its elements. If that is the case, how can I do it.
P.S- Tried this on both chrome and Firefox browser.
All,
I have finally managed to resolve the issue.
So the issue resolutions goes like this.
-The frame designed on the page were actually hidden.
-I had to switch to the hidden frame after switching to the main frame.
-Then the elements were then identified easily.
Problems what I faced:
1. In Firefox browser-The hidden frame was not detected in the 'Firefinder' when I checked with filter 'frame' which was detecting all the frames except the hidden frame. Same was the case with 'Firepath'
2. In Chrome browser- Though the document inside the main frame was displayed, traversing inside did not show the hidden iframe.
Solution:
In Firefox browser, inspecting the element using the HTML tab helped me to identify the hidden frame inside the main frame.
Carefully traversing the iframe hidden document helped me.
But, I am still not sure why the Chrome browser 'Inspect' doesn't show this frame.

Can't click overlapped element within a popup(not main window),how to scroll it to view?

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);");

Accessing multiple scroll bars using selenium

How to perform actions on the scroll bar present in an iFrame?
Issue 1:
I need to click on the link present in an iFrame which is displayed on scrolling the vertical bar. But when I try to click the link Selenium 2.0 is unable to find the element and it is scrolling the web page scroll bar.
Thanks in advance.
I think the best way to solve it is making your link visible through javascript (Changing the hidden property to visible).
Anyway, did you try sending a spacebar press using sendKeys? It will scroll down if you are already on the iframe
I used this to click the element - without seeing it (also in iframe). When I tried scrolling, or element.click(), the iframe scrollbar broke and test was unable to continue.
If you cannot find it like this, try using js to find it aswell.
WebElement element = getWebDriver().findElement(By.id("element_id"))
JavascriptExecutor jse = (JavascriptExecutor) getWebDriver();
jse.executeScript("arguments[0].click();", element);

Resources