summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/selenium/doc/FAQ.html
blob: 90299653d4336bdfd1e8d8732f961783985393d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.5: http://docutils.sourceforge.net/" />
<title>Selenium Frequently Asked Questions</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<h1 class="title">Selenium Frequently Asked Questions</h1>
<div class="document" id="selenium-frequently-asked-questions">
<!-- Please note that until there's a Q&A-specific construct available,
this FAQ will use section titles for questions.  Therefore
questions must fit on one line.  The title may be a summary of the
question, with the full question in the section body. -->
<p>This is a work in progress.  Please feel free to ask questions and/or
provide answers; send email to the Selenium users email address at <a class="reference" href="mailto:selenium-users&#64;lists.public.thoughtworks.org">selenium-users&#64;lists.public.thoughtworks.org</a>.</p>
<div class="contents topic" id="contents">
<p class="topic-title first"><a name="contents">Contents</a></p>
<ul class="auto-toc simple">
<li><a class="reference" href="#selenium" id="id2" name="id2">1   Selenium</a><ul class="auto-toc">
<li><a class="reference" href="#what-is-selenium-used-for" id="id3" name="id3">1.1   What is Selenium used for?</a></li>
<li><a class="reference" href="#why-can-t-i-script-google-com" id="id4" name="id4">1.2   Why can't I script google.com?</a></li>
<li><a class="reference" href="#how-can-i-run-my-test-against-a-foreign-or-remote-server-and-get-around-cross-site-scripting-security" id="id5" name="id5">1.3   How can I run my test against a foreign or remote server and get around cross-site scripting security?</a></li>
<li><a class="reference" href="#how-do-you-create-test-tables" id="id6" name="id6">1.4   How do you create test tables?</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="selenium">
<h1><a class="toc-backref" href="#id2" name="selenium">1   Selenium</a></h1>
<div class="section" id="what-is-selenium-used-for">
<h2><a class="toc-backref" href="#id3" name="what-is-selenium-used-for">1.1   What is Selenium used for?</a></h2>
<p>It is used for functional or system testing web applications. These tests
are also sometimes called acceptance, customer, or integration tests. Selenium is not meant for unit testing.</p>
</div>
<div class="section" id="why-can-t-i-script-google-com">
<h2><a class="toc-backref" href="#id4" name="why-can-t-i-script-google-com">1.2   Why can't I script google.com?</a></h2>
<p>Question:
<em>I was trying to write a simple script that does a google search. 
I have been running into all sorts of problems. Does this work for you?
Here is my test:</em> <table cellpadding="1" cellspacing="1" border="1">
  <tbody>
    <tr>
      <td rowspan="1" colspan="3">Test Type<br>
      </td>
    </tr>
    <tr>
      <td>open</td>
      <td>http://www.google.com/</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>type</td>
      <td>q</td>
      <td>testing tools</td>
    </tr>
    <tr>
      <td>click</td>
      <td>submitButton</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>.</p>
<p>Answer:
The quick answer is that because of cross-site scripting security built into
JavaScript engines in all browsers, you can't  edit the content of a web page
from another domain. The foreign page will probably load correctly and be visible
in the test runner window, but Selenium won't be able to query or edit its contents.
In other words, you can't run selenium on &quot;foo.com&quot; and
run a test that edits values and clicks buttons against &quot;bar.com&quot;. So, in
its current form, you can't &quot;script&quot; google.com because your script isn't
currently hosted on google.com. When Selenium and the application you are
testing is hosted on the same domain, however, you do not run into the
cross-site scripting security feature/limitation.</p>
<p>You read more about cross-site scripting here: <a class="reference" href="http://www.devarticles.com/c/a/JavaScript/JavaScript-Security/">http://www.devarticles.com/c/a/JavaScript/JavaScript-Security/</a></p>
<p>Also, if cross-site scripting security didn't exist, be careful about your 
field and button references in your tests. The current version
of Selenium uses the &quot;id&quot; attribute of the object you are referring to in your
test. The search field and submit button at google.com have &quot;name&quot; attributes,
but not not &quot;id&quot; attributes. Therefore, Selenium wouldn't be able to find the objects.
Future versions of Selenium will be able to search for objects by more than 
just the id attribute, though.</p>
</div>
<div class="section" id="how-can-i-run-my-test-against-a-foreign-or-remote-server-and-get-around-cross-site-scripting-security">
<h2><a class="toc-backref" href="#id5" name="how-can-i-run-my-test-against-a-foreign-or-remote-server-and-get-around-cross-site-scripting-security">1.3   How can I run my test against a foreign or remote server and get around cross-site scripting security?</a></h2>
<p>There are a few ways around cross-site scripting to access a remote server. 
You could use a combination of proxying and URL rewriting in Apache to 
trick the browser into the thinking the application and the testing tool 
are coming from the same domain.</p>
<p>Another option is to run Selenium as an &quot;HTA&quot; application, or &quot;HTML
Application&quot; in Internet Explorer. HTA applications run in the security
context of any trusted application on the client, so there is no cross-site
scripting limitation. (You can find out more here:
<a class="reference" href="http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp">http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp</a>) The
equivalent to this &quot;security-free&quot; client on the Mozilla side of the fence
would be to write a XUL wrapper/extension.</p>
<p>Also, please see the answer to the related question: &quot;Why can't I script google.com&quot;.</p>
</div>
<div class="section" id="how-do-you-create-test-tables">
<h2><a class="toc-backref" href="#id6" name="how-do-you-create-test-tables">1.4   How do you create test tables?</a></h2>
<p>The developers on the Selenium project use Mozilla Composer to 
create plain HTML text files for their tests.
By default, Mozilla Composer writes very clean HTML without any extra, unnecessary markup.</p>
<p>Future versions of Selenium may support RST (ReStructred Text), or wiki-table 
syntax, natively. However, you are free to use another format now, 
as long as you remember to generate the HTML files from your source files,
either during your build process or dynamically at run-time.</p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Author:</th><td class="field-body">Jason Huggins</td>
</tr>
<tr class="field"><th class="field-name">Created Date:</th><td class="field-body">11/05/2004</td>
</tr>
<tr class="field"><th class="field-name">Modified Date:</th><td class="field-body">11/05/2004</td>
</tr>
<tr class="field"><th class="field-name">Created With:</th><td class="field-body">reStructuredText: <a class="reference" href="http://docutils.sourceforge.net/rst.html">http://docutils.sourceforge.net/rst.html</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>