IzzyTwinkly
asked on
How would you locate an object in the Chrome web browser for Selenium?
Hi,
I am trying to click "Images" link in Google page.
The browser I am using is Chrome. you go to Google and enter something on the searchbox, then all the links are appeared. I was successful up to this point. After this, I right clicked my mouse on Image hyperlink on Google and selected "Inspect element' option. There was no 'id' for Images hyperlink
Some of codes I used for this were
var imageLink = driver1.FindElement(By.XPa th(@"//*[@ id=""hdtb_ msb""]/div [3]/a"));
var imageLink = driver1.FindElements(By.Cl assName("q _qs"))[2];
I also used LinkText and TagName, but the exceptions were returned.
I am using C# in Visual Studio 2013 ultimate version.
Can anybody help me with this?
I am trying to click "Images" link in Google page.
The browser I am using is Chrome. you go to Google and enter something on the searchbox, then all the links are appeared. I was successful up to this point. After this, I right clicked my mouse on Image hyperlink on Google and selected "Inspect element' option. There was no 'id' for Images hyperlink
Some of codes I used for this were
var imageLink = driver1.FindElement(By.XPa
var imageLink = driver1.FindElements(By.Cl
I also used LinkText and TagName, but the exceptions were returned.
I am using C# in Visual Studio 2013 ultimate version.
Can anybody help me with this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also I agree with what Dave said, google isn't the easiest site to automate and they also don't appreciate automation of their site. They will flag and redirect people they catch sending automated requests.
ASKER
Thanks Craig, I already tried Selenium IDE, and used the same code to click "Images" link. However, I got "InvalidOperaionException" error. error msg. says "unknown error: Element is not clickable at point (352, 89). Other element would receive the click: <div class="sbqs_c">...</div>
(Session info: chrome=41.0.2272.89)
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9a a096063e70 7c9cf),pla tform=Wind ows NT 6.1 SP1 x86_64)"
I used the following code:
driver1.Manage().Timeouts( ).Implicit lyWait(Tim eSpan.From Seconds(10 ));
driver1.FindElement(By.XPa th("(//a[c ontains(te xt(),'Imag es')])[2]" )).Click() ;
(Session info: chrome=41.0.2272.89)
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9a
I used the following code:
driver1.Manage().Timeouts(
driver1.FindElement(By.XPa
Have you tried the firefox driver?
The status of this bug is won't fix. https://code.google.com/p/selenium/issues/detail?id=2766
The status of this bug is won't fix. https://code.google.com/p/selenium/issues/detail?id=2766
Open in new window
You might want to pick an easier site than Google Images to develop your code and come back to this later.