Unable to recognize Web Elements on VM for particular Web applications

275 views
Skip to first unread message

nehu...@gmail.com

unread,
Jun 19, 2013, 8:42:17 AM6/19/13
to seleniu...@googlegroups.com
I have a set of selenium code that runs successfully on my system but fails when executed on VM. The test fails with message unable to identify web Element.

When I fetch the source code through WebDriver ( using getPageSource() ), I am able to get the entire elements present on page.

Also, script fails to recognize Web Element only for particular sites. (Offical Site so not able to share) but for rest of the application the code is running successfully.

I test application only on IE.

Please help what should I do in order to make my scripts run successfully on VM.

Mark Collin

unread,
Jun 19, 2013, 10:15:26 AM6/19/13
to seleniu...@googlegroups.com
I would guess that the VM is not as powerful as your dev machine and
it's taking longer to render the page.

Because it's taking longer to render the page it's probably checking for
an element before it has been rendered.

The way to fix it is to start using explicit waits:

WebDriverWait wait = new WebDriverWait(driver, 15, 100);
WebElement myElement =
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("myElement")));
> --
> You received this message because you are subscribed to the Google
> Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/selenium-users/1f63ee01-44e7-4b4b-bad8-e1cdd232bb3b%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

nehu...@gmail.com

unread,
Jun 21, 2013, 4:32:41 AM6/21/13
to seleniu...@googlegroups.com
Thanks Mark for your suggestion... I will give a check this and let you know...

nehu...@gmail.com

unread,
Jun 24, 2013, 12:12:54 AM6/24/13
to seleniu...@googlegroups.com
Hi Mark,

I tried your code but still problem persist. Actually the elements are rendered as the when i take the source code from web driver, I am able to get all the elements.

Also, I am trying this out on 512 RAM, is that the problem?

Please help.

Mark Collin

unread,
Jun 24, 2013, 3:57:50 AM6/24/13
to seleniu...@googlegroups.com
In that case we need to see your test code, the stack trace of the error and the html markup of the site you are testing.

nehu...@gmail.com

unread,
Jun 24, 2013, 7:47:03 AM6/24/13
to seleniu...@googlegroups.com
Hi Mark,

I am sharing piece of code and stack trace. Will not be able to share HTML part.

Code:

        String url = "http://ABCD";
       
        try
        {
            WebDriver driver = new InternetExplorerDriver();
            driver.get(url);
           
            WebElement we = driver.findElement(By.linkText("XYZ"));
            we.click();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }

Stack Trace:

org.openqa.selenium.NoSuchElementException: Unable to find element with link text == XYZ (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 625 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:28'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_39'
Driver info: driver.version: RemoteWebDriver
Session ID: 585f586f-a63a-4fc9-96d4-5d6ea59b1a00
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:458)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:226)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:263)
    at org.openqa.selenium.By$ByLinkText.findElement(By.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:218)
    at ESBTest.test(ESBTest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Mark Collin

unread,
Jun 24, 2013, 7:52:36 AM6/24/13
to seleniu...@googlegroups.com
Well your stack trace says there is no element that matches the following on your web page:

<a>XYZ</a>

Since you can't share the HTML I will have to assume that it is correct.

nehu...@gmail.com

unread,
Jun 24, 2013, 8:02:53 AM6/24/13
to seleniu...@googlegroups.com
The element is present on page which i verified by taking the source code of the page through getPageSource() function of webdriver.

nehu...@gmail.com

unread,
Jun 24, 2013, 8:03:28 AM6/24/13
to seleniu...@googlegroups.com
Also, the script is working fine when I execute it on my system.

Mark Collin

unread,
Jun 24, 2013, 8:12:53 AM6/24/13
to seleniu...@googlegroups.com
All of which implies you should be using an explicit wait as stated earlier in this thread.

nehu...@gmail.com

unread,
Jun 24, 2013, 8:19:05 AM6/24/13
to seleniu...@googlegroups.com
I tried that as well.... But it didn't worked... :( :( :(

Mark Collin

unread,
Jun 24, 2013, 8:22:19 AM6/24/13
to seleniu...@googlegroups.com
Sorry but with the information available I have nothing more to suggest

nehu...@gmail.com

unread,
Jun 25, 2013, 12:23:51 AM6/25/13
to seleniu...@googlegroups.com
Can anyone please help me out????

nehu...@gmail.com

unread,
Jun 28, 2013, 1:15:49 AM6/28/13
to seleniu...@googlegroups.com
Is Selenium Webdriver not designed to run on VMs????

Please reply.......

Nibu b

unread,
Jun 28, 2013, 1:50:47 AM6/28/13
to seleniu...@googlegroups.com
It will run on VM , We are running tests on VM only. 
Did you try changing your locator  and run? 

Jim Evans

unread,
Jun 28, 2013, 1:58:42 AM6/28/13
to seleniu...@googlegroups.com
At the risk of seeming incredibly impolite (which is entirely a function of how many beers I've had tonight), I run Selenium WebDriver almost exclusively in a VM environment. There is nothin preventing it from behaving properly in a VM.

nehu...@gmail.com

unread,
Jun 28, 2013, 3:01:46 AM6/28/13
to seleniu...@googlegroups.com
 Thanks JIM for your reply..... Is there any additional settings\configuration that needs to be done in order to execute scripts on VM?

Krishnan Mahadevan

unread,
Jun 28, 2013, 3:37:37 AM6/28/13
to Selenium Users
Nehu,

Lets start from the beginning.

What exactly are you facing as an issue here ?
What have you tried so far in terms of setting up a VM for WebDriver execution ?

Without stating any of these, answering your questions would be as good as shooting in the dark.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


On Fri, Jun 28, 2013 at 12:31 PM, <nehu...@gmail.com> wrote:
 Thanks JIM for your reply..... Is there any additional settings\configuration that needs to be done in order to execute scripts on VM?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

nehu...@gmail.com

unread,
Jun 28, 2013, 7:03:53 AM6/28/13
to seleniu...@googlegroups.com

I have a script which executes properly on my system. Created project on VM and imported selenium-java 2.23.1 jars. Copied test scripts on VMs. Done Environment variable settings and IE Settings as that I have on my system.

Piece of code that my script contains:



        try
        {
            WebDriver driver = new InternetExplorerDriver();
            driver.get(url);

             String pageSource = driver.getPageSource();
             log.info(pageSource);


           
            WebElement we = driver.findElement(By.linkText("XYZ"));

            we.click();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }



After all this setting I tried following:-
1. Executed above and encountered NoSuchElementException
2. Tried to check with other element but still the same
3. Tried to locate element by name and id but still the same
4. To ensure the element is rendered on the
page, I made my driver to explicitly wait for web element (as suggested earlier in this thread)and verified the existence of elements by fetching the source code of WebDriver ( using getPageSource() ).

5. After all this, I tried testing for other official sites & non-officially site and found that the issue persist for official sites and not for non-official sites

6. I tried to change the IE settings of my local system to one of the VM’s IE settings and see if I could replicate the issue. I did the respective changes but I couldn’t replicate the issue. I then also tried changing the IE settings on VM to what we keep here on local machines, still the issue on the VM was not solved.

 

Looking at the replies, I guess the issue is not with Selenium WebDriver but certain setting of VM are creating problems for selenium webdriver. Not sure…..

Hope I have addressed all your queries and you have a rough picture of my problem.

nehu...@gmail.com

unread,
Jul 1, 2013, 6:07:43 AM7/1/13
to seleniu...@googlegroups.com
Also,

We have QTP scripts that are working fabulous on VM for restricted sites.

 I am still not able to identify the cause why Selenium WebDriver is not able to locate web elements on VM for official sites.


On Wednesday, June 19, 2013 6:12:17 PM UTC+5:30, nehu...@gmail.com wrote:

neha sharma

unread,
Jul 3, 2013, 4:54:06 AM7/3/13
to seleniu...@googlegroups.com
 Do I need to do something related to port n all???
Some check or setting that I need to do prior to execution of my scripts?

Adem Dogu

unread,
Jul 17, 2014, 7:56:44 PM7/17/14
to seleniu...@googlegroups.com
Hi Neha,
Can you please try to use: driver.manage().window().maximize();
This does not make any sense but in some cases work fine.
Please let me know with the result.
Thanks,
Adem Dogu



Reply all
Reply to author
Forward
0 new messages