c# - Webdriver tests failing due to System.Net.WebException timeout -


c#

.net 4.5

vs 2013

nunit 3.2.1

webdriver , webdriver.support 2.53

so issue trying navigating ebay's sandbox login page , login. seems simple enough struggling page load before giving me system.net.webexception timeout error.

here link trying go https://signin.sandbox.ebay.com/

and here code looks doing this.

var ebaysandboxpage = new ebaysandboxloginpagemodel(driver); driver.manage().timeouts().setpageloadtimeout(timespan.fromseconds(200)); driver.navigate().gotourl(ebaysandboxloginpagemodel.sandboxurl); 

and here exception getting thrown every time try in firefox.

test name:  verifyitemssold test fullname: pomauctivatest.testsuite.postsaletestsuite<firefoxdriver>.verifyitemssold test source:    c:\git\pomauctivatest\pomauctivatest.testsuite\postsaletestsuite.cs : line 204 test outcome:   failed test duration:  0:00:00.0000001  result message:  onetimesetup: openqa.selenium.webdriverexception : http request remote webdriver server url http://localhost:7055/hub/session/80efbcbe-841d-4a53-a422-5e7498a0438b/element timed out after 60 seconds. ----> system.net.webexception : operation has timed out 

so question how change system.net.webrequest.timeout property? not using instance of webrequest. guess webdriver imagine there way me change value. can see have upped setpageloadtimeout() value exceed 2 min. in manual testing has been more enough.

here attempt @ @buaban's solution although mine still throwing exception.

        driver.manage().timeouts().setpageloadtimeout(timespan.fromseconds(120));         try         {             driver.navigate().gotourl(ebaysandboxloginpagemodel.sandboxurl);         }         catch (webdriverexception)         {          }         ebaysandboxpage.waitforelementvisible(driver, ebaysandboxloginpagemodel.usernamefieldselector);  

here waitforelementvisible() method looks like.

    public void waitforelementvisible(iwebdriver driver, element)     {         try         {             webdriverwait wait = new webdriverwait(driver, timespan.fromseconds(90));             wait.until(expectedconditions.elementisvisible(element));         }         catch (webdrivertimeoutexception)         {             takescreenshot(driver);             console.write("test failed trying wait element " + element.tostring() + " visible ");         }     } 

here definition of usernamefieldselector

public static usernamefieldselector = by.cssselector("#userid");

as florent b. mentioned in comment, page resources dead. have ignore exception wait element on page. see example below:

driver.manage().timeouts().setpageloadtimeout(timespan.fromseconds(30)); try {     driver.navigate().gotourl(@"https://signin.sandbox.ebay.com/"); } catch (exception) {     system.diagnostics.debug.writeline("some resources dead!"); } iwait<iwebdriver> wait = new defaultwait<iwebdriver>(driver); wait.timeout = timespan.fromseconds(10); wait.pollinginterval = timespan.frommilliseconds(300); wait.until(d => d.findelements(by.xpath("//span[text()='sign in']")).count > 0);  system.diagnostics.debug.writeline("sign in textbox loaded"); 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -