The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:
Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> Selenium

Pages: 1
fmtjatt
Member


Reged: 04/12/04
Posts: 293
Loc: California
driver.getpagesource casuing FF browser to close
      #717917 - 10/11/12 01:19 PM

Hi All,

I'm noticing that driver.getPageSource() command is causing my FF browser to close. Have anyone else noticed this problem?

Code:
getPageText = driver.getPageSource();

Error:
Caused by Premature end of Content-Length delimited message body (expected: 33859; received: 28956


Failure
Error communicating with the remote browser. It may have died. Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_35' Driver info: driver.version: RemoteWebDriver



Edited by fmtjatt (10/11/12 01:22 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
fmtjatt
Member


Reged: 04/12/04
Posts: 293
Loc: California
Re: driver.getpagesource casuing FF browser to close [Re: fmtjatt]
      #717981 - 10/13/12 12:28 PM

No one experienced their browser closing unexpectedly? Now it is happening on every run in about 2 or 3rd loop.

Here is the code
Code:

getPageText = driver.getPageSource();

String[] split1;
String[] split2;
split1 = getPageText.split("Confirmation Number");
split2 = split1[1].split("Comments");
getConfirmationNumber = split2[0];



Post Extras: Print Post   Remind Me!   Notify Moderator  
Corey_G
Veteran


Reged: 09/14/01
Posts: 4281
Loc: Boston, MA
Re: driver.getpagesource casuing FF browser to close [Re: fmtjatt]
      #717983 - 10/13/12 03:28 PM

firstly, which language bindings are you using. syntax looks like Java? you need to always specify, or else we are all left guessing.

assuming java, `getPageSource()` will return a String, containing the page source. If it doesn't, it is a bug and should be reported to the selenium project's bug tracker.

However, what does "Now it is happening on every run in about 2 or 3rd loop." mean? I can't parse that sentence into sensical english. What exactly are you trying to do?

does a simple test ever exhibit the browser-closing behavior?

such as:
- instantiate webdriver
- load page
- get page source

... and you are missing some details that would make this easier to reproduce or debug. What is `driver` in this context? Is it an instance of FirefoxDriver or of RemoteWebDriver? If you are going to post code samples, please post everything relevant.

also, use proper naming conventions in your code. your string variables are named like methods (i.e. getPageText).

also, Have you considered using regular expressions to extract the confirmation number, rather than the string splitting dance?

hth,

-Corey

--------------------
Corey Goldberg
Homepage: goldb.org
Twitter: twitter.com/cgoldberg
Google+: gplus.to/cgoldberg


Post Extras: Print Post   Remind Me!   Notify Moderator  
fmtjatt
Member


Reged: 04/12/04
Posts: 293
Loc: California
Re: driver.getpagesource casuing FF browser to close [Re: Corey_G]
      #717985 - 10/13/12 07:19 PM

Corey,

Yes, I'm using Java with FireFoxDriver. The entire code runs through several loops. The same code works for the first few loops and then eventually browser closes with the error mentioned above. Someone else said that page HTML could not be well formatted and it could be causing the issue.


Here is the entire code of this method which is being called in another method which runs through the loops. Hope it makes sense.

Code:

public String getApptConfirmationNumber(int rowNum) throws InterruptedException{
int i = rowNum;
String getConfirmationNumber =null;
int expectedRowCount = 2;
String getPageText =null;

List <WebElement> rowCount = driver.findElements(By.xpath("//table[@class='content_border']/tbody/tr[9]/td/table/tbody/tr"));

if(rowCount.size()<=1){
Reporter.log("There are no appointments in current appointment section");
Assert.assertEquals(rowCount, expectedRowCount, "Unable to get confirmation number as there are " +
"no current appointments available");
}else{
driver.findElement(By.xpath("//table[@class='content_border']/tbody/tr[9]/td/table/tbody/tr["+i+"]/td[4]/a")).click();
Thread.sleep(5000);

getPageText = driver.getPageSource();

String[] split1;
String[] split2;
split1 = getPageText.split("Confirmation Number");
split2 = split1[1].split("Comments");
getConfirmationNumber = split2[0];
driver.findElement(By.xpath("//input[@value=' Cancel ']")).click();
Thread.sleep(5000);
getPageText = null;
}

return getConfirmationNumber;
}





Edited by fmtjatt (10/13/12 07:22 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Corey_G
Veteran


Reged: 09/14/01
Posts: 4281
Loc: Boston, MA
Re: driver.getpagesource casuing FF browser to close [Re: fmtjatt]
      #717988 - 10/14/12 09:35 AM

you are missing something. your code doesn't ever instantiate FireFoxDriver(). How does your method know what 'driver' is?

also,. for debugging purposes, you should trim down your code to the *simplest possible example* that exhibits your problem.

can you remove everything except a tiny snippet of code that shows the problem?

basically, 3 lines of code:

- instantiate webdriver
- load page
- get page source

--------------------
Corey Goldberg
Homepage: goldb.org
Twitter: twitter.com/cgoldberg
Google+: gplus.to/cgoldberg


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 9 anonymous users are browsing this forum.

Moderator:  LNB, AJ, michaeljf 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 1528

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5