List of usage examples for org.openqa.selenium WebDriver getTitle
String getTitle();
From source file:com.gargoylesoftware.htmlunit.javascript.host.DocumentTest.java
License:Apache License
/** * Test setting and reading the title for an existing title. * @throws Exception if the test fails//from www.j ava2s .c om */ @Test @Alerts("correct title") public void settingTitle() throws Exception { final String html = "<html><head><title>Bad Title</title></head>\n" + "<body>\n" + "<script>\n" + " document.title = 'correct title';\n" + " alert(document.title)\n" + "</script>\n" + "</body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals(getExpectedAlerts()[0], driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.DocumentTest.java
License:Apache License
/** * Test setting and reading the title for when the is not in the page to begin. * @throws Exception if the test fails//w w w. ja v a2 s.c om */ @Test @Alerts("correct title") public void settingBlankTitle() throws Exception { final String html = "<html><head><title></title></head>\n" + "<body>\n" + "<script>\n" + " document.title = 'correct title';\n" + " alert(document.title)\n" + "</script>\n" + "</body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals(getExpectedAlerts()[0], driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.DocumentTest.java
License:Apache License
/** * @throws Exception if the test fails//from w w w. j av a2s . c o m */ @Test @Alerts("foo") public void title() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest(){\n" + " alert(document.title)\n" + "}\n" + "</script></head>\n" + "<body onload='doTest()'>\n" + "</body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals(getExpectedAlerts()[0], driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for inline text nodes. * @throws Exception if the test fails// ww w. j av a 2 s. c o m */ @Test @Alerts({ "Some Text", "9", "3", "Some Text", "#text" }) public void textNode() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " alert(text1.data);\n" + " alert(text1.length);\n" + " alert(text1.nodeType);\n" + " alert(text1.nodeValue);\n" + " alert(text1.nodeName);\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>Some Text</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for setting the data property of a text node. * @throws Exception if the test fails/*ww w .j av a 2 s . c om*/ */ @Test @Alerts({ "Some New Text", "Some New Text" }) public void setData() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " text1.data='Some New Text';\n" + " alert(text1.data);\n" + " alert(text1.nodeValue);\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>Some Text</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for setting the nodeValue property of a text node. * @throws Exception if the test fails/*from w w w. jav a2 s . c om*/ */ @Test @Alerts({ "Some New Text", "Some New Text" }) public void setNodeValue() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " text1.nodeValue='Some New Text';\n" + " alert(text1.data);\n" + " alert(text1.nodeValue);\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>Some Text</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for appendData of a text node. * @throws Exception if the test fails/* w ww . ja va2 s . com*/ */ @Test @Alerts("Some Text Appended") public void appendData() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " text1.appendData(' Appended');\n" + " alert(text1.data);\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>Some Text</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for deleteData of a text node. * @throws Exception if the test fails// w w w. j av a 2 s .c o m */ @Test @Alerts({ "Some Text", "Some", "Some", "me", "" }) public void deleteData() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " try {\n" + " text1.deleteData(5, 11);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(4, 5);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(1, 0);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(0, 2);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(0, 2);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>Some Not So New Text</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * Regression test for deleteData of a text node. * @throws Exception if the test fails//from ww w .j a v a2 s. c o m */ @Test @Alerts(DEFAULT = { "", "", "", "" }, IE = { "", "", "", "exception" }) public void deleteDataEmptyImput() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " try {\n" + " text1.deleteData(0, 1);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(0, 0);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(0, 1);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(0, -1);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>-</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.dom.CharacterDataTest.java
License:Apache License
/** * @throws Exception if the test fails/* ww w.ja va 2 s . c o m*/ */ @Test @Alerts(DEFAULT = { "exception", "exception", "exception", "exception" }, IE = { "exception", "exception", "abcde", "exception" }) public void deleteDataInvalidStart() throws Exception { final String html = "<html><head><title>First</title><script>\n" + "function doTest() {\n" + " var div1=document.getElementById('div1');\n" + " var text1=div1.firstChild;\n" + " try {\n" + " text1.deleteData(-1, 4);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(20, 4);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(20, 0);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + " try {\n" + " text1.deleteData(20, -18);\n" + " alert(text1.data);\n" + " } catch (e) { alert('exception') }\n" + "}\n" + "</script></head><body onload='doTest()'>\n" + "<div id='div1'>abcde</div></body></html>"; final WebDriver driver = loadPageWithAlerts2(html); assertEquals("First", driver.getTitle()); }