Sorry, posted the wrong test case. Here is the correct one:
package org.tellurium.java;
import org.tellurium.test.java.TelluriumJUnitTestCase;
import org.tellurium.test.mock.MockHttpServer;
import org.tellurium.module.StyleModule;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class StyleTestCase extends TelluriumJUnitTestCase {
private static MockHttpServer server;
@BeforeClass
public static void setUp(){
server = new MockHttpServer(8080);
server.registerHtml("/style.html", StyleModule.HTML_BODY);
server.start();
connectSeleniumServer();
}
@Test
public void testGetSeparatorAttribute(){
StyleModule lm = new StyleModule();
lm.defineUi();
connectUrl("http://localhost:8080/style.html");
String[] style = lm.getCSS("errorDiv", "color");
assertNotNull(style);
for(String st: style){
System.out.println("\t" + st);
}
}
@AfterClass
public static void tearDown(){
server.stop();
}
}
On Wed, Dec 9, 2009 at 10:33 AM, Jian Fang <[email protected]> wrote:
> I created the following UI module
>
> package org.tellurium.module
>
> import org.tellurium.dsl.DslContext
>
> public class StyleModule extends DslContext {
> public static String HTML_BODY = """
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <html>
> <head>
> <title>My first styled page</title>
> <style type="text/css">
>
> .error {
> color:red;
> }
> * {
> margin:0;
> }
> </style>
> </head>
> <body>
>
> <div id="errorDiv" class="error" style="">
> A message cannot contain a blank message body.
> <br/>
> </div>
> </body>
> </html>
> """
>
> public void defineUi() {
> ui.Div(uid: "errorDiv", clocator: [class: "error"])
> }
> }
>
> with the a test case,
>
> package org.tellurium.example.test.java;
>
> import org.tellurium.example.other.UserModule;
> import org.junit.AfterClass;
> import org.junit.BeforeClass;
> import org.junit.Test;
> import static org.junit.Assert.assertNotNull;
> import org.tellurium.test.java.TelluriumJavaTestCase;
> import org.tellurium.test.mock.MockHttpServer;
> import org.tellurium.dsl.DiagnosisResponse;
> import org.tellurium.dsl.DiagnosisOption;
>
> public class UserTestCase extends TelluriumJavaTestCase {
> private static MockHttpServer server;
>
> @BeforeClass
> public static void setUp(){
> server = new MockHttpServer(8080);
> server.registerHtmlBody("/account.html", UserModule.HTML_BODY);
> server.start();
> connectSeleniumServer();
> }
>
> @Test
> public void testGetSeparatorAttribute(){
> UserModule lm = new UserModule();
> lm.defineUi();
> connectUrl("http://localhost:8080/account.html");
> lm.disableJQuerySelector();
> lm.doCreateAccount();
> connectUrl("http://localhost:8080/account.html");
> lm.useJQuerySelector();
> lm.doCreateAccount();
> }
>
> @Test
> public void testTriggerEventOn(){
> UserModule lm = new UserModule();
> lm.defineUi();
> connectUrl("http://localhost:8080/account.html");
> lm.type("accountEdit.accountName", "ccc");
> lm.triggerEventOn("accountEdit.accountName", "blur");
> }
>
> @Test
> public void testDiagnose(){
> UserModule lm = new UserModule();
> lm.defineUi();
> connectUrl("http://localhost:8080/account.html");
> DiagnosisResponse resp =
> lm.getDiagnosisResult("accountEdit.accountName");
> assertNotNull(resp);
> resp.show();
>
> resp = lm.getDiagnosisResult("accountEdit.save", new
> DiagnosisOption());
> assertNotNull(resp);
> resp.show();
> }
>
> @Test
> public void testGenerateHTML(){
> UserModule lm = new UserModule();
> lm.defineUi();
> System.out.print(lm.generateHtml("subnav"));
> System.out.print(lm.generateHtml("issueResult"));
> System.out.print("\nGenerate html for all UI modules\n");
> System.out.print(lm.generateHtml());
> }
>
>
> @Test
> public void testDump(){
> UserModule lm = new UserModule();
> lm.defineUi();
> lm.dump("ConsumersPage");
> lm.dump("search");
> }
>
> @AfterClass
> public static void tearDown(){
> server.stop();
> }
> }
>
> The result I got back is "rgb(26, 26, 26)".
>
> I also tried to use jQuery+Firebug to inspect the runtime dom as described
> in
>
> http://code.google.com/p/aost/wiki/TelluriumJQueryFirebug
>
> also got back the same color "rgb(26, 26, 26)".
>
> I am not a CSS expert, what color does "rgb(26, 26, 26)" represent?
>
> Thanks,
>
> Jian
>
> On Wed, Dec 9, 2009 at 9:47 AM, Jian Fang <[email protected]>wrote:
>
>> The getCSS() method is implemented using jQuery's css selector:
>>
>> http://docs.jquery.com/CSS/css
>>
>> Not sure why it does not work for you. I will create a test case with your
>> html and see what I can get back.
>>
>> Thanks,
>>
>> Jian
>>
>>
>> On Wed, Dec 9, 2009 at 2:26 AM, mugua <[email protected]> wrote:
>>
>>> in my case ,I have html codes and css below:
>>> HTML;
>>> <div id="errorDiv" class="error" style="">
>>> A message cannot contain a blank message body.
>>> <br/>
>>> </div>
>>>
>>> CSS:
>>> .error {
>>> color:red;
>>> }
>>> * {
>>> margin:0;
>>> }
>>> when I am trying to use getCSS("errorDiv","color") it returns with
>>> value rgb(0,0,0) in Firefox 3.0
>>> but the right value should be red or rgb(255,0,0)
>>>
>>> How can I get the expected value?
>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google Groups
>>> "tellurium-users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<tellurium-users%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/tellurium-users?hl=en.
>>>
>>>
>>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"tellurium-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tellurium-users?hl=en.