Please help me about xpath for selenium

128 views
Skip to first unread message

2010Zanoza2

unread,
Nov 19, 2014, 3:19:32 PM11/19/14
to fire...@googlegroups.com
I need to get xpath for web elements for selenium. I have firefox 33.1.1, firebug 2.0.6 and firepath plug-in 0.9.7.
I need to see xpath as something like that: IWebElement query = driver.FindElement(By.XPath(".//*[@id='sb_ifc0']"));
But I see the xpath as "html/body/div[1]/div[3]/div[1]/div[1]/div[3]/div/div/div/form/fieldset[2]/div/div/div/div/div[3]/div/input[3]" for the main google search prompt as example.
And the code like:

 try
            {
                IWebElement query = driver.FindElement(By.XPath("html/body/div[1]/div[3]/div[1]/div[1]/div[3]/div/div/div/form/fieldset[2]/div/div/div/div/div[3]/div/input[3]"));   //i've tried to find the google search prompt by xpass
            }

            catch
            {
                System.Windows.Forms.MessageBox.Show("Login field is not found");
            }

gives me an exception....
 
Please help me to solve the problem.
Reply all
Reply to author
Forward
0 new messages