@@ -1519,25 +1519,19 @@ public void setTimeout() throws Exception {
15191519 final String html = "<html>\n "
15201520 + "<head>\n "
15211521 + " <script>\n "
1522+ + LOG_TEXTAREA_FUNCTION
15221523 + " function test() {\n "
15231524 + " var id = window.setTimeout( function() { log('result'); }, 20);\n "
15241525 + " log(typeof id);\n "
15251526 + " log('done');\n "
15261527 + " }\n "
1527- + "\n "
1528- + " function log(x) {\n "
1529- + " document.getElementById('log').value += x + '\\ n';\n "
1530- + " }\n "
15311528 + "</script></head>\n "
15321529 + "<body onload='test()'>\n "
1533- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1530+ + LOG_TEXTAREA
15341531 + "</body>\n "
15351532 + "</html>\n " ;
15361533
1537- final WebDriver driver = loadPage2 (html );
1538- Thread .sleep (200 );
1539- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1540- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1534+ loadPageVerifyTextArea2 (html );
15411535 }
15421536
15431537 /**
@@ -1549,25 +1543,19 @@ public void setTimeoutWithParams() throws Exception {
15491543 final String html = "<html>\n "
15501544 + "<head>\n "
15511545 + " <script>\n "
1546+ + LOG_TEXTAREA_FUNCTION
15521547 + " function test() {\n "
15531548 + " var id = window.setTimeout( function(p1) { log(p1); }, 20, 42);\n "
15541549 + " log(typeof id);\n "
15551550 + " log('done');\n "
15561551 + " }\n "
1557- + "\n "
1558- + " function log(x) {\n "
1559- + " document.getElementById('log').value += x + '\\ n';\n "
1560- + " }\n "
15611552 + "</script></head>\n "
15621553 + "<body onload='test()'>\n "
1563- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1554+ + LOG_TEXTAREA
15641555 + "</body>\n "
15651556 + "</html>\n " ;
15661557
1567- final WebDriver driver = loadPage2 (html );
1568- Thread .sleep (200 );
1569- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1570- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1558+ loadPageVerifyTextArea2 (html );
15711559 }
15721560
15731561 /**
@@ -1579,26 +1567,20 @@ public void setTimeoutCode() throws Exception {
15791567 final String html = "<html>\n "
15801568 + "<head>\n "
15811569 + " <script>\n "
1570+ + LOG_TEXTAREA_FUNCTION
15821571 + " function test() {\n "
15831572 + " try{\n "
15841573 + " var id = window.setTimeout('log(7)');\n "
15851574 + " log('done 2');\n "
15861575 + " } catch(e) { log(e); }\n "
15871576 + " }\n "
1588- + "\n "
1589- + " function log(x) {\n "
1590- + " document.getElementById('log').value += x + '\\ n';\n "
1591- + " }\n "
15921577 + "</script></head>\n "
15931578 + "<body onload='test()'>\n "
1594- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1579+ + LOG_TEXTAREA
15951580 + "</body>\n "
15961581 + "</html>\n " ;
15971582
1598- final WebDriver driver = loadPage2 (html );
1599- Thread .sleep (200 );
1600- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1601- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1583+ loadPageVerifyTextArea2 (html );
16021584 }
16031585
16041586 /**
@@ -1610,26 +1592,20 @@ public void setTimeoutWrongParams() throws Exception {
16101592 final String html = "<html>\n "
16111593 + "<head>\n "
16121594 + " <script>\n "
1595+ + LOG_TEXTAREA_FUNCTION
16131596 + " function test() {\n "
16141597 + " try{\n "
16151598 + " window.setTimeout();\n "
16161599 + " log('done');\n "
16171600 + " } catch(e) { log(e instanceof TypeError); }\n "
16181601 + " }\n "
1619- + "\n "
1620- + " function log(x) {\n "
1621- + " document.getElementById('log').value += x + '\\ n';\n "
1622- + " }\n "
16231602 + "</script></head>\n "
16241603 + "<body onload='test()'>\n "
1625- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1604+ + LOG_TEXTAREA
16261605 + "</body>\n "
16271606 + "</html>\n " ;
16281607
1629- final WebDriver driver = loadPage2 (html );
1630- Thread .sleep (200 );
1631- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1632- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1608+ loadPageVerifyTextArea2 (html );
16331609 }
16341610
16351611 /**
@@ -1674,26 +1650,20 @@ public void setInterval() throws Exception {
16741650 final String html = "<html>\n "
16751651 + "<head>\n "
16761652 + " <script>\n "
1653+ + LOG_TEXTAREA_FUNCTION
16771654 + " var id;\n "
16781655 + " function test() {\n "
16791656 + " id = window.setInterval( function() { log('result'); clearInterval(id); }, 20);\n "
16801657 + " log(typeof id);\n "
16811658 + " log('done');\n "
16821659 + " }\n "
1683- + "\n "
1684- + " function log(x) {\n "
1685- + " document.getElementById('log').value += x + '\\ n';\n "
1686- + " }\n "
16871660 + "</script></head>\n "
16881661 + "<body onload='test()'>\n "
1689- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1662+ + LOG_TEXTAREA
16901663 + "</body>\n "
16911664 + "</html>\n " ;
16921665
1693- final WebDriver driver = loadPage2 (html );
1694- Thread .sleep (200 );
1695- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1696- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1666+ loadPageVerifyTextArea2 (html );
16971667 }
16981668
16991669 /**
@@ -1705,26 +1675,20 @@ public void setIntervalWithParams() throws Exception {
17051675 final String html = "<html>\n "
17061676 + "<head>\n "
17071677 + " <script>\n "
1678+ + LOG_TEXTAREA_FUNCTION
17081679 + " var id;\n "
17091680 + " function test() {\n "
17101681 + " id = window.setInterval( function(p1) { log(p1); clearInterval(id); }, 20, 42);\n "
17111682 + " log(typeof id);\n "
17121683 + " log('done');\n "
17131684 + " }\n "
1714- + "\n "
1715- + " function log(x) {\n "
1716- + " document.getElementById('log').value += x + '\\ n';\n "
1717- + " }\n "
17181685 + "</script></head>\n "
17191686 + "<body onload='test()'>\n "
1720- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1687+ + LOG_TEXTAREA
17211688 + "</body>\n "
17221689 + "</html>\n " ;
17231690
1724- final WebDriver driver = loadPage2 (html );
1725- Thread .sleep (200 );
1726- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1727- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1691+ loadPageVerifyTextArea2 (html );
17281692 }
17291693
17301694 /**
@@ -1736,27 +1700,21 @@ public void setIntervalCode() throws Exception {
17361700 final String html = "<html>\n "
17371701 + "<head>\n "
17381702 + " <script>\n "
1703+ + LOG_TEXTAREA_FUNCTION
17391704 + " var id;\n "
17401705 + " function test() {\n "
17411706 + " try{\n "
17421707 + " id = window.setInterval('log(7); clearInterval(id);' );\n "
17431708 + " log('done 2');\n "
17441709 + " } catch(e) { log(e); }\n "
17451710 + " }\n "
1746- + "\n "
1747- + " function log(x) {\n "
1748- + " document.getElementById('log').value += x + '\\ n';\n "
1749- + " }\n "
17501711 + "</script></head>\n "
17511712 + "<body onload='test()'>\n "
1752- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1713+ + LOG_TEXTAREA
17531714 + "</body>\n "
17541715 + "</html>\n " ;
17551716
1756- final WebDriver driver = loadPage2 (html );
1757- Thread .sleep (200 );
1758- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1759- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1717+ loadPageVerifyTextArea2 (html );
17601718 }
17611719
17621720 /**
@@ -1768,26 +1726,20 @@ public void setIntervalWrongParams() throws Exception {
17681726 final String html = "<html>\n "
17691727 + "<head>\n "
17701728 + " <script>\n "
1729+ + LOG_TEXTAREA_FUNCTION
17711730 + " function test() {\n "
17721731 + " try{\n "
17731732 + " window.setInterval();\n "
17741733 + " log('done');\n "
17751734 + " } catch(e) { log(e instanceof TypeError); }\n "
17761735 + " }\n "
1777- + "\n "
1778- + " function log(x) {\n "
1779- + " document.getElementById('log').value += x + '\\ n';\n "
1780- + " }\n "
17811736 + "</script></head>\n "
17821737 + "<body onload='test()'>\n "
1783- + " <textarea id='log' cols='80' rows='40'></textarea> \n "
1738+ + LOG_TEXTAREA
17841739 + "</body>\n "
17851740 + "</html>\n " ;
17861741
1787- final WebDriver driver = loadPage2 (html );
1788- Thread .sleep (200 );
1789- final String text = driver .findElement (By .id ("log" )).getAttribute ("value" ).trim ().replaceAll ("\r " , "" );
1790- assertEquals (String .join ("\n " , getExpectedAlerts ()), text );
1742+ loadPageVerifyTextArea2 (html );
17911743 }
17921744
17931745 /**
0 commit comments