I am not able to find the Hidden Element even with Actions | Selenium Forum
M
Posted on 26/03/2016
Hi Team,

I am not able to find the Hidden Elements Even with Actions class

WebElement google_apps = dr.findElement(By.xpath("//*[@id='gbwa']/div[1]/a"));
WebElement gmail = dr.findElement(By.xpath("//*[@id='gb23']/span[1]"));
Actions act = new Actions(dr);
act.moveToElement(google_apps).build().perform();
act.moveToElement(gmail).build().perform();

In the above code first i found the google_apps and second line i found gmail icon and i created actions class and passed driver object in actions constructor.

then i wrote act.move to element statements with build and perform functions also

M
Replied on 28/03/2016

While Running the Above code, i am getting the below error.

[b:3sufjinm][u:3sufjinm]Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Offset within element cannot be scrolled into view: (0, 0): [object HTMLSpanElement][/u:3sufjinm][/b:3sufjinm]
Command duration or timeout: 30 milliseconds
Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:11:55'
System info: host: 'ULTP_374', ip: '192.168.111.218', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_75'
Session ID: 914006d6-a13a-48e0-b651-d28611a6f13d
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=45.0.1}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.interactions.MoveMouseAction.perform(MoveMouseAction.java:39)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:50)
at Uploading_Picture_In_Gmail.main(Uploading_Picture_In_Gmail.java:27)
Caused by: org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Offset within element cannot be scrolled into view: (0, 0): [object HTMLSpanElement]
Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:11:55'


M
Replied on 28/03/2016

[quote:3p4dp1ts]I am not able to find the Hidden Elements Even with Actions class
[/quote:3p4dp1ts]

you can't automate hidden element.


M
Replied on 28/03/2016

Hello Sir,

we can do Mouse movement in the webpage through Actions class and click on that icon and further we can go to the required link

This was explained in Module 14 Mouse Movement concept in Selenium

In the Screenshot Gmail icon is the Hidden Element, which resides under Google_Apps icon

so i have written a code first find the google apps icon and clicked that icon by actions class and after that i code will find gmail icon and clicks it with actions class

Please Correct Me if i am wrong

Responsive image

M
Replied on 28/03/2016

[quote:3g1ldv8f]("//*[@id='gb23']/span[1]"));[/quote:3g1ldv8f]

this xpath will not work. watch module about dynamic xpath. Google is very hard to automate. not good for learning selenium.