SimpleBrowserDotNet / SimpleBrowser.WebDriver

A webdriver for SimpleBrowser
Apache License 2.0
43 stars 16 forks source link

selenium can't find class #36

Closed xz013 closed 7 years ago

xz013 commented 7 years ago

hello, i'm using selenium and can't find this calss var element = driver.FindElement(By.XPath("//*[contains(@class, 'rc-imageselect-table-33')]")).Text; //works

from this link https://patrickhlauke.github.io/recaptcha/

and html have the class http://prntscr.com/d3co2r

and give me this ex: http://prntscr.com/d3cpgd any body can help !

kevingy commented 7 years ago

Using Chrome, I opened https://patrickhlauke.github.io/recaptcha/. After the page loaded, I searched for 'rc-imageselect-table-33'. I don't see the class in the source. I see where the class rc-imageselect-table-33 is defined in Google's CSS, but I don't see it used anywhere:

image

It looks like what you're trying to do is to use SimpleBrowser in conjunction with Google's Recaptcha. Keep in mind that if the element you are attempting to find is added to the DOM by JavaScript (that is, it's not in the page HTML downloaded before JavaScript would typically run), SimpleBrowser won't ever find it. SimpleBrowser does not support JavaScript. I'm almost 100% sure that Google's Recaptcha requires Javascript and is loaded using Javascript after the host page has finished loading.

Try this. Load the page with SimpleBrowser. After the page is loaded, look at the source of the page using the Browser.CurrentHtml property. This is what SimpleBrowser searches. If your class isn't there, it's not going to be found.

It doesn't matter what you can see in Chrome. It only matters what you can see in SimpleBrowser.

xz013 commented 7 years ago

click at the box to can see captcha and class ,i'm using firefox see i find it http://prnt.sc/d3e38l

so i want catch the this class to can scrap screenshot and click at the box

kevingy commented 7 years ago

Wow! You completely ignored everything I said about JavaScript. Let's try this again ...

This is the entire content of https://patrickhlauke.github.io/recaptcha/, as seen by SimpleBrowser:

<!DOCTYPE html>
<html>
<head>
<title>Google reCAPTCHA test</title>
<meta charset=utf-8>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<h1>Google reCAPTCHA test</h1>
<p>Adds the vanilla <a href="https://www.google.com/recaptcha">reCAPTCHA</a> widget, for testing...</p>
<div class="g-recaptcha" data-sitekey="6Ld2sf4SAAAAAKSgzs0Q13IZhY02Pyo31S2jgOB5"></div>
</body>
</html>

Because SimpleBrowser doesn't support JavaScript, the content of api.js never gets exectuted. Since the javascript doesn't get executed, the ReCaptcha does not exist. Therefore, in SimpleBrowser, the check box does not exist. If the check box doesn't exist, it can't be clicked to see the table of images. Therefore, the table of images with the class you are looking for does not exist. It is not possible to do what you are trying to do with SimpleBrowser.

Again ...

It doesn't matter what you can see in Chrome. It only matters what you can see in SimpleBrowser.

Similarly, it doesn't matter what you can see in Firefox. It only matters what you can see in SimpleBrowser.

xz013 commented 7 years ago

yeah i see ,but i sure there ppl using selenium webdrive ,same as me and catch the element and can click image the point them code at dll :( can't see it so i hope u can help me to can catch the element and can click the image

kevingy commented 7 years ago

I'm not saying Selenium can't do it. I'm saying SimpleBrowser can't do it. Since you're using Firefox, perhaps you would do better with the Selenium Firefox WebDriver instead of the Selenium SimpleBrowser WebDriver.

xz013 commented 7 years ago

thanks so much for trying helping me , i know ppl use it with firefox and works great ,can you please help me with code or steps to can do what i want catch this element and click to box !

kevingy commented 7 years ago

Good luck!