[prev in list] [next in list] [prev in thread] [next in thread]
List: htmlunit-user
Subject: Re: [Htmlunit-user] Updated style
From: Ahmed Ashour <asashour () yahoo ! com>
Date: 2009-08-30 12:33:15
Message-ID: 90433.25754.qm () web112212 ! mail ! gq1 ! yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
* You must subscribe to the list before posting.
* Please open a bug report.
Yours,
Ahmed----
Blog: http://asashour.blogspot.com
________________________________
Subject: Auto-discard notification
Note: Forwarded message is attached.
The attached message has been automatically discarded.
-----Inline Message Follows-----
Hello,
I was wondering if someone can help me figure out this problem. I'm trying to \
retrieve a new page after clicking on a named anchor tag. The same page should return \
with an updated style for a table element. However, after executing the code below \
the same page is returned without the modified style attribute.
Any help is appreciated,
Scott
PS
I'm using HtmlUnit 2.5 stable build
import com.gargoylesoftware..htmlunit.*;
import com.gargoylesoftware.htmlunit.html.*;
import java..io.*;
import java.util.*;
import java.net.*;
public class Experiment
{
public static void main(String[] argv)
{
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
webClient.setCssEnabled(true);
webClient.setThrowExceptionOnFailingStatusCode(true);
webClient.setPrintContentOnFailingStatusCode(true);
webClient.setTimeout(10000);
webClient.setJavaScriptEnabled(true);
try
{
WebRequestSettings req = new WebRequestSettings( new \
URL(http://www.pockettutor.com/test/experiment..html)); req.setCharset("utf-8");
HtmlPage page = webClient.getPage(req);
webClient.waitForBackgroundJavaScriptStartingBefore(10000);
// find the anchor tag
List<?> anchors = page.getByXPath("//a");
if (anchors.size() == 1)
{
HtmlElement a = (HtmlElement)anchors.get(0);
HtmlPage page2 = a.click();
try
{
Thread.sleep(5000);
}
catch (Exception e ){}
if (page2.asXml().equalsIgnoreCase(page.asXml()))
{
System.out.println("Same Page!!!!");
}
else
{
System.out.println("Different Page!!!");
}
}
}
catch (IOException e) { e.printStackTrace(); }
}
}
start: 0000-00-00 end: 0000-00-00
[Attachment #5 (text/html)]
<html><head><style type="text/css"><!-- DIV {margin:0px;} \
--></style></head><body><div style="font-family:times new roman, new york, times, \
serif;font-size:12pt"><DIV></DIV> <DIV>Hi,</DIV>
<DIV><BR>* You must subscribe to the list before posting.</DIV>
<DIV>* Please open a bug report.</DIV>
<DIV> </DIV>
<DIV>Yours,</DIV>
<DIV>Ahmed</DIV>----<BR>Blog: http://asashour.blogspot.com
<DIV><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Auto-discard \
notification<BR></FONT><BR>Note: Forwarded message is attached.<BR><BR>The attached \
message has been automatically discarded.<BR><BR>-----Inline Message \
Follows-----<BR><BR> <TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">Hello,</SPAN></FONT></P></DIV> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">I was wondering if someone can help me figure out this problem. I'm trying to \
retrieve a new page after clicking on a named anchor tag. The same page should return \
with an updated style for a table element. However, after executing the code below \
the same page is returned without the modified style attribute.</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Any help is appreciated,</SPAN></FONT> \
<P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Scott</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> PS</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"></SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I'm using HtmlUnit 2.5 stable \
build</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">import com.gargoylesoftware.htmlunit.*;</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">import com.gargoylesoftware.htmlunit.html.*;</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">import java.io.*;</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">import \
java.util.*;</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">import java.net.*;</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">public class Experiment</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">{</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> public static void \
main(String[] argv)</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> {</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> WebClient webClient = new \
WebClient(BrowserVersion.FIREFOX_3);</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.setCssEnabled(true);</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.setThrowExceptionOnFailingStatusCode(true);</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.setPrintContentOnFailingStatusCode(true);</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.setTimeout(10000);</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.setJavaScriptEnabled(true);</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> try</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> {</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
WebRequestSettings req = new WebRequestSettings( new URL(<A \
href="http://www.pockettutor.com/test/experiment.html" target=_blank \
rel=nofollow>http://www.pockettutor.com/test/experiment.html</A>));</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
req.setCharset("utf-8");</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> HtmlPage \
page = webClient.getPage(req);</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
webClient.waitForBackgroundJavaScriptStartingBefore(10000);</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
// find the anchor tag</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
List<?> anchors = page.getByXPath("//a");</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
if (anchors.size() == 1)</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
{</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
HtmlElement a = (HtmlElement)anchors.get(0);</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
HtmlPage page2 = a.click();</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
try</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
{</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
Thread.sleep(5000);</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
}</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
catch (Exception e ){}</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
if (page2.asXml().equalsIgnoreCase(page.asXml()))</SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
{</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
System.out.println("Same Page!!!!");</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
}</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
else</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN \
style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
{</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
System.out.println("Different Page!!!");</SPAN></FONT> <P class=MsoNormal><FONT \
face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> \
}</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> \
}</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> }</SPAN></FONT> \
<P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> catch (IOException e) { \
e.printStackTrace(); }</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P \
class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial"> }</SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> \
</SPAN></FONT> <P class=MsoNormal><FONT face=Arial size=2><SPAN style="FONT-SIZE: \
10pt; FONT-FAMILY: Arial"> </SPAN></FONT> <P class=MsoNormal><FONT face=Arial \
size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: \
Arial">}</SPAN></FONT></P></TD></TR></TBODY></TABLE><BR>start: 0000-00-00 end: \
0000-00-00</DIV></div><br>
</body></html>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic