Re: [selenium-users] JSF Menus and Selenium webdriver problem

3,338 views
Skip to first unread message

Krishnan Mahadevan

unread,
Jul 25, 2012, 1:53:50 PM7/25/12
to seleniu...@googlegroups.com
Sample code that have so far. 
Html source of the page. 

Both these would help someone in this forum help you. 

On Wednesday, July 25, 2012, Sandy wrote:
Dear All,

      I am working on a jsf web application using selenium/eclipse/java platform. I wanted to click a dynamic menu of application in this
structure:-

        Menu------
                     |-------Sub menu
                                           |-------------sub-sub menu item  * 

I wanted to click this item but neither xpath is working nor direct call of sub-sub menu item... This problem is because 
webdriver is not able to call the mouseover also no direct click is working as I had tried to call by ID/Class
All invain...:(... Please anyone can suggest me a solution...

Thanks in advance..

Regards

Sandeep

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/daYPSphc23IJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
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/

anji prassana

unread,
Jul 26, 2012, 3:33:11 AM7/26/12
to seleniu...@googlegroups.com
Hi sandy,
Direct xpath never works because webdriver doesn't finds an element until and unless desired element is been currently visible on the screen as it's not attached to the DOM.
Definitely you would get succeeded with either mouse or Keyboard actions. For this, you may use 'Webdriverbackedselenium' instance and get use to relevant mouse/keyboard events to traverse across the menu.I hope WebDriverBackedSeleniums Mouse events would help you in great while dealing with menus because these are well proven and are robust.
 
Probably you aware of it.However, For instance..
/* driver refers to the instance of the webdriver class you have created prior to this statement.
URL is the URL of the application you are testing.
Simialar to URL you passed as an argument to driver.get()  function.
*/
  WebDriverBackedSelenium sel=new WebDriverBackedSelenium(driver,URL);
  sel.typeKeys(..) //if you want to drive the menu with keyboard
  sel.mouseClick(...) //if you wanna drive the menu with mouse actions
 
for example:
selenium.mouseClick("xpath=//body/div/div[19]/table/tbody/tr/td/div/div/table/tbody/tr/td[3]"); //Click Mail

Mark Collin

unread,
Jul 26, 2012, 3:58:42 AM7/26/12
to seleniu...@googlegroups.com

Not true, some corrections/clarifications:

 

·         WebDriver can find any element you can reference with an XPath. 

·         An element does not have to be visible on the screen to be in the DOM.

·         WebDriver will only allow you to perform user actions on elements that are visible to the end user, you can do other things with elements that are not visible.

anji prassana

unread,
Jul 26, 2012, 4:44:45 AM7/26/12
to seleniu...@googlegroups.com
Thanks Mike. Thank you very much for your nice clarification.
 
while working on the GXT AWT application, I came to the assumption as elements won't be attached to the DOM unless they are visible on the screen;Where i had a tree view which loads its childrens by reading an XML file found in the server path. If the tree has more number of childrens which upon expand goes beyond the screen but able to control with Vertical scroll bar on Right. There, we found that, firebug doesn't displays the childrens which are not on the screen.But, once the childrens get onto the screen we found those in the firebug DOM tree. So, I though of it as elements not in the screen won't be found in the DOM tree. But, I hope it might be true in case of elements constructing via XML [which is dynamic in nature]. But,your point may be true in case of static elements.
 
However, I need to work on it once again to justify my answer.

Sandy

unread,
Jul 26, 2012, 6:57:18 AM7/26/12
to seleniu...@googlegroups.com
Thanks Mike...

          Yes the point number 3 of yours, was what I meant in my above comment...
But anyways I tried two things:-

1) WebDriverBackedSelenium (got exception mentioned below)
2) import org.openqa.selenium.interactions.Actions; (worked partially)

import java.util.concurrent.TimeUnit;

//import org.openqa.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
//import org.openqa.selenium.remote.server.handler.FindChildElement;
//import org.openqa.grid.selenium.*;
//import org.openqa.grid.selenium.utils.*;
import com.thoughtworks.selenium.Selenium;

public class Call_details
{
public static void main(String args[])
{
    WebDriver Driver = new FirefoxDriver();
     String baseUrl = "http://192.168.149.24/myapp/";
     Selenium selenium = new WebDriverBackedSelenium(Driver, baseUrl);
     Actions builder = new Actions(Driver);
     
     
     
        Driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
        Driver.get(baseUrl);
        Driver.findElement(By.name("txt_username")).sendKeys("one1opt1");
        Driver.findElement(By.name("txt_password")).sendKeys("one1opt1");
        Driver.findElement(By.name("Submit")).click();
        Driver.findElement(By.linkText("RSSP")).click();
        Driver.findElement(By.id("loginForm:submit")).click();
        //WebElement tagElement = Driver.findElement(By.xpath("//div[contains(@id,'ddl_ANAL_span')]"));
        //builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_ANAL_span')]"))).build().perform();// This worked but after performing a mouse over it didn;t continued in next step :(
        //Driver.findElement(By.xpath("//div[contains(@id,'ddl_ANAL_span')]")).click();
        //builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRANA_ANAL')]"))).build().perform();
        //Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRANA_ANAL')]")).click();
        //builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_CD_CDRANA')]"))).build().perform();
        //Driver.findElement(By.xpath("//div[contains(@id,'ddl_CD_CDRANA')]")).click();
       
        selenium.mouseOver("//div[contains(@id,'ddl_ANAL_span')]"); // This didn't worked--- With a weird exception mentioned below
        //selenium.mouseOver("//div[contains(@id,'ddl_CDRANA_ANAL')]");
        //selenium.mouseOver("//div[contains(@id,'ddl_CD_CDRANA')]");
        //selenium.click("//div[contains(@id,'ddl_CD_CDRANA')]");
        //selenium.waitForPageToLoad("30000");       

}   
   
}

Exception got with WebDriverBackedSelenium :-

Exception in thread "main" com.thoughtworks.selenium.SeleniumException: TypeError: b is undefined
Command duration or timeout: 265 milliseconds

Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_05'
Driver info: driver.version: RemoteWebDriver
Session ID: 576e511e-2afa-49e0-9a00-828982cce782
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:41)
    at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:38)
    at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:144)
    at org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:74)
    at com.thoughtworks.selenium.DefaultSelenium.mouseOver(DefaultSelenium.java:269)
    at Call_details.main(Call_details.java:38)
Caused by: org.openqa.selenium.WebDriverException: TypeError: b is undefined
Command duration or timeout: 265 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_05'
Driver info: driver.version: RemoteWebDriver
Session ID: 576e511e-2afa-49e0-9a00-828982cce782
    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:498)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:407)
    at org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary.executeScript(JavascriptLibrary.java:87)
    at org.openqa.selenium.internal.seleniumemulation.MouseEvent.handleSeleneseCommand(MouseEvent.java:39)
    at org.openqa.selenium.internal.seleniumemulation.MouseEvent.handleSeleneseCommand(MouseEvent.java:1)
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:32)
    ... 5 more

--

To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/daYPSphc23IJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

anji prassana

unread,
Jul 26, 2012, 7:40:10 AM7/26/12
to seleniu...@googlegroups.com
Hi sandy,
  Hope you are addicted to Webdriver :).
 You forget the fact that any Selenium RC related call [WebDriverBackedSelenium in our case],   Here, Selenium.mouseOver(.....) you should specify what's that identifier is..Is it 'xpath' or 'id' or 'css' etc.. as follows..
 
Selenium.mouseOver("xpath=//div[contains(@id,'ddl_CDRANA_ANAL')]");
 
Correct your Call accordingly...

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kzfafyIYA28J.

Sandy

unread,
Jul 26, 2012, 8:18:41 AM7/26/12
to seleniu...@googlegroups.com, anji...@yahoo.co.in
Thanks Anji... :)  actually it is xpath... let me give a try... currently my steps are running too fast that selenium.waitForPageToLoad("50000") don't seem to be working...

Regards
Sandeep

Sandy

unread,
Jul 26, 2012, 8:31:17 AM7/26/12
to seleniu...@googlegroups.com, anji...@yahoo.co.in
Alas... same Exception after adding xpath
selenium.mouseOver("xpath=//div[contains(@id,'ddl_ANAL_span')]"); also...

 what this "TypeError: b is undefined Command duration or timeout: 188 milliseconds" Is it about timeout ?

Muzzamil

unread,
Jul 26, 2012, 9:04:37 AM7/26/12
to seleniu...@googlegroups.com
i have same problem related to mouse over but still suffering from it. may be selenium 2.14.0 is work for you, i cant able to click on sub-sub menu item by 2.14.0

try this code




ele= Menu item
ele1= Sub menu item
ele2=sub sub menu item




Actions builder = new Actions(driver);

builder.dragAndDrop(ele, ele1 ).perform();
Thread.sleep(5000);
builder.dragAndDrop(ele1, ele1).click(ele2).perform();

Thanks


To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/nZwDAKWLP8AJ.

Sandy

unread,
Jul 26, 2012, 10:23:25 AM7/26/12
to seleniu...@googlegroups.com
Dear Ansari,

        Can u post the detail code...?
Till then you can use following:-

WebDriver Driver = new FirefoxDriver();
Actions builder = new Actions(Driver);
 builder.moveToElement(Driver.findElement(By.xpath("your expression").build().perform();
Thread.sleep(1000L);
 Driver.findElement(By.xpath("your expression")).isSelected();


Repeat this for all sub items and don't forgot to put the thread.sleep interval... My code is also suffering from this... :(

Regards
Sandeep

Muzzamil

unread,
Jul 26, 2012, 10:48:23 AM7/26/12
to seleniu...@googlegroups.com
Sandy i have already used this code  and still i cant click elements in View may javascript will be helpful there.

i will send u code if i will get solution 

Thanks

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ba--r3fod5YJ.

Muzzamil

unread,
Jul 26, 2012, 11:09:15 AM7/26/12
to seleniu...@googlegroups.com
Sandy ,

  WebElement ele = driver.findElement(By.xpath("//div[3]/ul/li[3]/a/span"));
 WebElement ele1 = driver.findElement(By.xpath("//li[3]/ul/li[3]/a/span"));
         
            Thread.sleep(5000);
            ele.click();
            WebElement ele2 = driver.findElement(By.xpath("//li[3]/ul/li[3]/ul/li/a/span"));
          
            ele1.click();
           Thread.sleep(5000);
           ele2.click();


its work for me now may be because i have changed browser today
Mozilla F-14.0.1
selenium-2.24.1

Try if work then tell me

Thanks
Message has been deleted

Sandy

unread,
Jul 26, 2012, 11:20:51 AM7/26/12
to seleniu...@googlegroups.com
Ok... actually I am slo using an alternate approach of WebDriverBackedSelenium

here is the code:-


WebDriver Driver = new FirefoxDriver();
    Selenium selenium = new WebDriverBackedSelenium(
Driver,"myapp_url");
   
        selenium.open("myapp_url");
        selenium.type("name=txt_username", "one1opt1");
        selenium.type("name=txt_password", "one1opt1");
        selenium.click("name=Submit");
        selenium.waitForPageToLoad("50000");// this wait is not working ;;;(
        selenium.click("link=TMRS");
        selenium.waitForPageToLoad("50000");//this wait is not working ;;;(
        selenium.click("id=loginForm:submit");
selenium.waitForPageToLoad("50000");//this wait is not working ;;;(

        selenium.mouseOver("xpath=//div[contains(@id,'ddl_ANAL_span')]");
        selenium.mouseOver("xpath=//div[contains(@id,'ddl_CDRANA_ANAL')]");
        selenium.mouseOver("xpath=//div[contains(@id,'ddl_CD_CDRANA')]");
        selenium.click("xpath=//div[contains(@id,'ddl_CD_CDRANA')]");
        selenium.waitForPageToLoad("30000");       
Sandy ,
Thanks


Pankaj Dhapola

unread,
Jul 26, 2012, 1:50:55 PM7/26/12
to seleniu...@googlegroups.com
Hey Sandy,
Can you use

WebElement menu1We = driver.findElement(By.....);
Mouse mouse = ((HasInputDevices) driver).getMouse();
mouse.mouseDown(((Locatable)menu1We).getCoordinates());

similary go on expanding/unhiding menu2, see if even mouseover() works?
Before using this make sure that you have inspected DOM very well, to identify which of the HTML tag attribute has onclick, onmouseover etc attibutes attached to call that JavaScript code that makes menu appear/hide/toggle.
Because you may see a Link<A>, but the event firing Tag may be <DIV>, In this ages DOM manipulation has been very complex.

or similarly can you explore org.openqa.selenium.Mouse interface, or other mouse actions related class in WebDriver.

I had similar problem with JavaScript hiding menus, I got resolved using Mouse interface though.

Good Luck
;)

Sandy

unread,
Jul 27, 2012, 4:08:37 AM7/27/12
to seleniu...@googlegroups.com
Hi All,

Its Solved!!!! 

My problem have been solved ultimately for JSF menus.. The issue was that web driver was not able to get focus, so I had put some thread.sleeps, which helped in solving the problem,
Here is the code:- 

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import com.thoughtworks.selenium.Selenium;
import java.util.regex.Pattern;

public class Call_details
{
public static void main(String args[]) throws Throwable
{
WebDriver Driver = new FirefoxDriver();
String baseUrl = "myapp_url";
new WebDriverBackedSelenium(Driver,"myapp_url");
Actions builder = new Actions(Driver);
((HasInputDevices) Driver).getMouse();
 
   Driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
Driver.get(baseUrl);
Driver.findElement(By.name("txt_username")).sendKeys("user");
Driver.findElement(By.name("txt_password")).sendKeys("pwd");
Driver.findElement(By.name("Submit")).click();
Driver.findElement(By.linkText("RSSP")).click();
Driver.findElement(By.id("loginForm:submit")).click();
builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_ANAL_span')]"))).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.xpath("//div[contains(@id,'ddl_ANAL_span')]")).isSelected();
Thread.sleep(1000L);
builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRANA_ANAL')]"))).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRANA_ANAL')]")).isSelected();
Thread.sleep(1000L);
builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRLA_CDRANA')]"))).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.xpath("//div[contains(@id,'ddl_CDRLA_CDRANA')]")).isSelected();
Thread.sleep(1000L);
builder.moveToElement(Driver.findElement(By.xpath("//div[contains(@id,'ddl_CD_CDRANA')]"))).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.xpath("//div[contains(@id,'ddl_CD_CDRANA')]")).click();
Thread.sleep(1000L);
}
}

Thanks to Anji, Mike, Ansari and pankaj for their valuable responses.... :)

Mark Collin

unread,
Jul 27, 2012, 7:19:49 AM7/27/12
to seleniu...@googlegroups.com

If you are using thread.sleep you are doing it wrong.  You should use an explicit wait instead.

 

You test now has 8 seconds of wait time, that means you have added 8 seconds to every test run for no real reason.  If you keep doing this your tests will soon take so long to run they will become unusable.

--

You received this message because you are subscribed to the Google Groups "Selenium Users" group.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/4aPiq4HHokwJ.

Sandy

unread,
Jul 27, 2012, 3:16:27 PM7/27/12
to seleniu...@googlegroups.com
Now... I just wanna say... I quit :( ..

I have spend too much time and when I thought the problem was solved using thread.sleep... Mike pointed rightly on explicit wait..
I tried really hard for two hours to test and execute the the code... but all invain... web driver is not able to focus properly... I am only able to view the hidden menus using the thread.sleep and explicit wait is just getting stuck on step 2 and showing time out exceptions.. and none of further mouse over events are not get shown..

I am wondering why selenium IDE is capable of doing things efficiently and web driver is not(automation of web ).. Yes web driver have edge of programming flexibility but... in comparison to IDE it is lacking the flexibility of Selenium IDE.. Now really don't know which way to go ... should I search for some other utility or should I mine again the things in selenium web driver(which are not moving currently a inch)...

Atleast good alternative of mouseover should had been be given... Anyways will see tomorrow.. what to do...

till then lets focus on Olympic  opening ceremony..... :)

Mark Collin

unread,
Jul 30, 2012, 5:17:19 AM7/30/12
to seleniu...@googlegroups.com

IDE has its roots in Selenium RC.

 

Selenium RC used to use JavaScript to fire events which meant that you could do things that an end user could not (Like clicking on hidden buttons, interacting with elements off the screen, etc). Selenium RC was a good attempt but had issues that WebDriver has overcome.

 

WebDriver has been specifically designed to only enable you to do what an end user can do, so you can no longer interact with hidden elements because an end user cannot do this. 

 

If you have test involves you clicking a button that is not visible should it pass?  If it does what are you going to do when your website goes live and it turns out that this hidden button is never made visible, your test still passes so there is no bug right, oh hang on yes there is and it’s a biggie!

 

Do you have a publically visible page showing the functionality you are trying to automate?

 

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Sandy
Sent: 27 July 2012 20:16
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: JSF Menus and Selenium webdriver problem

 

Now... I just wanna say... I quit :( ..

--

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

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ViTv4RzJK-sJ.

Sandy

unread,
Jul 30, 2012, 6:40:33 AM7/30/12
to seleniu...@googlegroups.com
Thanks Mark... Actually I have started with only web driver and have no idea about Selenium RC..  But after reading on internet that webdriver is an upgrade, 
so i thought to invest my time in researching this as an alternative to agile testing. Currently everything is so irritatingly manual that it really takes time to execute each test case one by one. So after discussing with my team, I took this initiative to automate the test cases and making a correct process of testing.

               I started with IMacros, but that also have some problems and it varies from machine to machine and not suitable for kind of implementation as it not free.

Also my tests need to be executed on JSF platform and here the components that are pain points:-

            This kind of menus are hard to automate in JSF when Id's are also generated automatically and menu sub items are hidden and you can
not make any action on hidden items ( from above link  ---> File---> Save As--->Save All.., so directly clicking save all is not possible as it is not visible.
Yes I have achieved the visibility using thread.sleep but after your remarks I tried one by one for all menu items, but it was not able to get focus, as it 
was skipping the menu and sub menu items to quickly:-

         builder.moveToElement(Driver.findElement(By.xpath("//div[contains(text(),' *main menuitem-name* ')]"))).build().perform();
        new WebDriverWait(Driver, 10, 50).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[contains(text(),'*item-name*')]")));
      builder.moveToElement(Driver.findElement(By.xpath("//div[contains(text(),' *main menu-sub-item-name* ')]"))).build().perform();
        new WebDriverWait(Driver, 10, 50).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[contains(text(),' *main menu-sub-item-name* ')]")));
      builder.moveToElement(Driver.findElement(By.xpath("//div[contains(text(),' *main menu-sub-sub-item-name* ')]"))).build().perform();
        new WebDriverWait(Driver, 10, 50).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[contains(text(),' *main menu-sub-sub-item-name* ')]")));
     Driver.findElement(By.xpath("//span[contains(text(),' main menu-sub-sub-item-name ')]")).click();

for testing I also replaced  elementToBeClickable to  elementToBeSelected... but it didn't worked..

2) Selenium IDE can fill the readonly input text boxes as web driver was unable to do so, I needed to fill it for a date field as selecting the month/date/year was very complex using a javascript date popup.

All component of our web project are based on "http://livedemo.exadel.com/richfaces-demo/richfaces/"; So this page reflects all functionalities and components which I wanted to automate...

My first problem is Drop Down Menu, though i resolved using sleep method but I also feel it should be bettered but I don't have mouse over method, even using wedriverbacked selenium, I wasn't able to achieve it...


To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

Mark Collin

unread,
Jul 30, 2012, 9:17:18 AM7/30/12
to seleniu...@googlegroups.com

OK I’ve had a look at it and the HTML is making my eyes bleed.  What on earth were they thinking when they designed that??

 

For a start it’s invalid HTML:

 

http://validator.w3.org/check?uri=http%3A%2F%2Flivedemo.exadel.com%2Frichfaces-demo%2Frichfaces%2FdropDownMenu.jsf%3Fc%3DdropDownMenu%26tab%3Dusage&charset=%28detect+automatically%29&doctype=Inline&group=0

 

Secondly it seems there are problems waiting for elements to appear based upon mouse overs when using an Actions object.

 

I’ve automated a scenario where you mouse over the File button and then click the new button, this is however a bit messy:

 

WebDriver driver = new FirefoxDriver();

 

//Get the page we are automating

driver.get("http://livedemo.exadel.com/richfaces-demo/richfaces/dropDownMenu.jsf?c=dropDownMenu&tab=usage");

 

//Find the elements we are going to interact with on the page

WebElement dropDownMenuContainer = driver.findElement(By.xpath("(//div[@class='sample-container'])[1]/descendant::form"));

WebElement dropDownMenuOptionFile = dropDownMenuContainer.findElement(By.xpath("./table/descendant::tr/td/div[div[text()='File']]"));

By dropDownMenuOptionNewLocator = By.xpath("(//div[@class='sample-container'])[1]/descendant::form/table/descendant::tr/td/descendant::div[contains(@class, 'rich-menu-item')][span[.='New']]");

WebElement dropDownMenuOptionNew = dropDownMenuContainer.findElement(dropDownMenuOptionNewLocator);

 

//Hacky way to get access to the mouse

Mouse mouse = ((HasInputDevices)driver).getMouse();

//Set up an explicit wait object that waits up to 5 seconds for something, checking the condition every 500 ms

WebDriverWait performWait = new WebDriverWait(driver, 5, 500);

 

//Mouse over the file button

mouse.mouseMove(((Locatable) dropDownMenuOptionFile).getCoordinates());

//Wait for the new button to appear

performWait.until(visibilityOfElementLocated(dropDownMenuOptionNewLocator));

//Mouse over new button

mouse.mouseMove(((Locatable) dropDownMenuOptionNew).getCoordinates());

//Click new button

mouse.click(((Locatable) dropDownMenuOptionNew).getCoordinates());

 

driver.quit();

 

We seem to have 2 problems at the moment:

 

1.       It seems that implicit waits don’t work for visibility when using the Actions object.

2.       Breaking an actions object into two parts results in the mouse location being lost.  So if I create an actions object to do a hover action the mouse seems to be reset to an unknown location after .perform(), so the drop down menu is not made visible whilst the wait condition is taking place resulting in a test failure.

 

Looks like we have a bug to raise later on J

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ViTv4RzJK-sJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--

You received this message because you are subscribed to the Google Groups "Selenium Users" group.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Ik9tjLOiGUAJ.

Sandy

unread,
Aug 1, 2012, 3:32:27 AM8/1/12
to seleniu...@googlegroups.com
Thanks Mark... for taking time to see my problem...

I know its a bug kind of thing, but can't say more about it...

But you gave another very good idea of w3c validator tool.. Its really great !!! I am deploying the same on my local machine so that I can test by build locally for this.

Thanks for sharing such a good tool... :) Keep sharing your treasure of ideas.... :) It really helps...:-)

To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ViTv4RzJK-sJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

Sandy

unread,
Aug 7, 2012, 5:57:43 AM8/7/12
to seleniu...@googlegroups.com
Hey Thom ...

                There are few factors I found during searching the solution here are those:-

1) Put a Thread.sleep(1000L) method, instead of the explicit wait, (I don't know what the reason, but explicit wait is not working here)

2) Follow following sequence using webdriver:-
             a) Click the main menu.
             b) Click the submenu item on main menu. putting (thread.sleep)
             c) Once the submenu appears, put a sleep method and using action builder focus on first item of submenu (you may don't want to click it just use Selected method)  
             d)  Now  select the item you want to click.. (put thread sleep again)
             e) Hit Click on item.

Here is probable code for you.. Looks bad but its a working solution..


Actions actions = new Actions(driver);
Driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);

builder.moveToElement(Driver.findElement(By.id("menuForm:viewMenu")).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.id("'menuForm:viewMenu")).isSelected();
Thread.sleep(1000L);
builder.moveToElement(Driver.findElement(By.id("menuForm:languageMenu")).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.id("menuForm:languageMenu")).isSelected();
Thread.sleep(1000L);
// Here the sub menu will get focus due to thread sleep method
builder.moveToElement(Driver.findElement(By.id("write first sub menu item id here")).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.id("write first sub menu item id here")).isSelected();
Thread.sleep(1000L);
builder.moveToElement(Driver.findElement(By.id("menuForm:fr:anchor")).build().perform();
Thread.sleep(1000L);
Driver.findElement(By.id("menuForm:fr:anchor")).click();
Reply all
Reply to author
Forward
0 new messages