SimpleBrowserDotNet / SimpleBrowser.WebDriver

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

Shoulkd this example work? #21

Closed aaronportier closed 10 years ago

aaronportier commented 10 years ago

Not sure if this is the right place or not? I get no element found for wd.FindElement(By.Id("gbqfq")).Click(); this is all the code: [TestClass] public class UnitTest3 { [TestMethod] public void Debit_WithValidAmount_UpdatesBalance() { //IWebDriver wd = new RemoteWebDriver(DesiredCapabilities.Firefox()); IWebDriver wd = new SimpleBrowser.WebDriver.SimpleBrowserDriver(); try { wd.Navigate().GoToUrl("https://www.google.com/"); wd.FindElement(By.Id("gbqfq")).Click(); wd.FindElement(By.Id("gbqfq")).Clear(); wd.FindElement(By.Id("gbqfq")).SendKeys("fiserv"); wd.FindElement(By.Id("gbqfb")).Click(); if (!wd.FindElement(By.TagName("html")).Text.Contains("Fiserv: Financial Services Technology, Mobile Banking ...")) { Console.Error.WriteLine("verifyTextPresent failed"); } } finally { wd.Quit(); }

Teun commented 10 years ago

Generally speaking, this should be possible. I assume that the element gbqfq is the input box and gbqfb is the submit button. I don't know Google's homepage very well, but I do know that it contains some nifty javascript. Not sure if it depends on that though.

Could you try to do the same thing with Firefox/Chrome with javascript disabled? See what happens then?

Teun Op 19 mei 2014 02:36 schreef "aaronportier" notifications@github.com:

Not sure if this is the right place or not? I get no element found for wd.FindElement(By.Id("gbqfq")).Click(); this is all the code: [TestClass] public class UnitTest3 { [TestMethod] public void Debit_WithValidAmount_UpdatesBalance() { //IWebDriver wd = new RemoteWebDriver(DesiredCapabilities.Firefox()); IWebDriver wd = new SimpleBrowser.WebDriver.SimpleBrowserDriver(); try { wd.Navigate().GoToUrl("https://www.google.com/"); wd.FindElement(By.Id("gbqfq")).Click(); wd.FindElement(By.Id("gbqfq")).Clear(); wd.FindElement(By.Id("gbqfq")).SendKeys("fiserv"); wd.FindElement(By.Id("gbqfb")).Click(); if (!wd.FindElement(By.TagName("html")).Text.Contains("Fiserv: Financial Services Technology, Mobile Banking ...")) { Console.Error.WriteLine("verifyTextPresent failed"); } } finally { wd.Quit(); }

— Reply to this email directly or view it on GitHubhttps://github.com/Teun/SimpleBrowser.WebDriver/issues/21 .

Teun commented 10 years ago

I've checked the page. If you load without javascript enabled, the elements you try to use are indeed not on the page. There is an input field with name q (no id) and a input[type=submit] with name btnG. If you use those, I'm sure it will work.

However, if you want to use Google's homepage like real users would, SimpleBrowser is not your tool. You could look into PhantomJS, which does include javascript support. It adds some overhead (because it will have to download and parse those scripts too, making it only a bit faster than just using Chrome).

Teun Op 19 mei 2014 07:55 schreef "Teun Duynstee" teun@duynstee.com:

Generally speaking, this should be possible. I assume that the element gbqfq is the input box and gbqfb is the submit button. I don't know Google's homepage very well, but I do know that it contains some nifty javascript. Not sure if it depends on that though.

Could you try to do the same thing with Firefox/Chrome with javascript disabled? See what happens then?

Teun Op 19 mei 2014 02:36 schreef "aaronportier" notifications@github.com:

Not sure if this is the right place or not? I get no element found for wd.FindElement(By.Id("gbqfq")).Click(); this is all the code: [TestClass] public class UnitTest3 { [TestMethod] public void Debit_WithValidAmount_UpdatesBalance() { //IWebDriver wd = new RemoteWebDriver(DesiredCapabilities.Firefox()); IWebDriver wd = new SimpleBrowser.WebDriver.SimpleBrowserDriver(); try { wd.Navigate().GoToUrl("https://www.google.com/"); wd.FindElement(By.Id("gbqfq")).Click(); wd.FindElement(By.Id("gbqfq")).Clear(); wd.FindElement(By.Id("gbqfq")).SendKeys("fiserv"); wd.FindElement(By.Id("gbqfb")).Click(); if (!wd.FindElement(By.TagName("html")).Text.Contains("Fiserv: Financial Services Technology, Mobile Banking ...")) { Console.Error.WriteLine("verifyTextPresent failed"); } } finally { wd.Quit(); }

— Reply to this email directly or view it on GitHubhttps://github.com/Teun/SimpleBrowser.WebDriver/issues/21 .

aaronportier commented 10 years ago

Terun,

I have been attempting to work with the project for a while(I love the ideas behind it) and have not been able to figure it out. I have a few questions for you if you will?

  1. Is there anymore documentation than on the Github project?
  2. Does this project have a way to change already written Selenium tests to use Simple Browser?
  3. What Selenium commands/locators can you use which can you not?
  4. How do you recommend debugging tests using Simple Browser?

Thank You very much for any help.

Aaron

On Mon, May 19, 2014 at 2:23 AM, Teun notifications@github.com wrote:

I've checked the page. If you load without javascript enabled, the elements you try to use are indeed not on the page. There is an input field with name q (no id) and a input[type=submit] with name btnG. If you use those, I'm sure it will work.

However, if you want to use Google's homepage like real users would, SimpleBrowser is not your tool. You could look into PhantomJS, which does include javascript support. It adds some overhead (because it will have to download and parse those scripts too, making it only a bit faster than just using Chrome).

Teun Op 19 mei 2014 07:55 schreef "Teun Duynstee" teun@duynstee.com:

Generally speaking, this should be possible. I assume that the element gbqfq is the input box and gbqfb is the submit button. I don't know Google's homepage very well, but I do know that it contains some nifty javascript. Not sure if it depends on that though.

Could you try to do the same thing with Firefox/Chrome with javascript disabled? See what happens then?

Teun Op 19 mei 2014 02:36 schreef "aaronportier" notifications@github.com:

Not sure if this is the right place or not? I get no element found for wd.FindElement(By.Id("gbqfq")).Click(); this is all the code: [TestClass] public class UnitTest3 { [TestMethod] public void Debit_WithValidAmount_UpdatesBalance() { //IWebDriver wd = new RemoteWebDriver(DesiredCapabilities.Firefox()); IWebDriver wd = new SimpleBrowser.WebDriver.SimpleBrowserDriver(); try { wd.Navigate().GoToUrl("https://www.google.com/"); wd.FindElement(By.Id("gbqfq")).Click(); wd.FindElement(By.Id("gbqfq")).Clear(); wd.FindElement(By.Id("gbqfq")).SendKeys("fiserv"); wd.FindElement(By.Id("gbqfb")).Click(); if (!wd.FindElement(By.TagName("html")).Text.Contains("Fiserv: Financial Services Technology, Mobile Banking ...")) { Console.Error.WriteLine("verifyTextPresent failed"); } } finally { wd.Quit(); }

— Reply to this email directly or view it on GitHub< https://github.com/Teun/SimpleBrowser.WebDriver/issues/21> .

— Reply to this email directly or view it on GitHub https://github.com/Teun/SimpleBrowser.WebDriver/issues/21#issuecomment-43469380 .

Teun commented 10 years ago

I've added a wiki page with links and some tips. I hope this answers your questions.

https://github.com/Teun/SimpleBrowser.WebDriver/wiki/Developing-with-SimpleBrowser.WebDriver