File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
from selenium import webdriver
2
2
3
3
4
+ BASE_URL = "http://localhost"
5
+
4
6
WEBDRIVERS = {
5
7
"firefox" : webdriver .Firefox ,
6
8
"chrome" : webdriver .Chrome
Original file line number Diff line number Diff line change
1
+ import re
1
2
import sys
2
3
3
4
from selenium import webdriver
4
5
import pytest
5
6
6
7
from codebender_testing .config import WEBDRIVERS
8
+ from codebender_testing .config import BASE_URL
7
9
8
10
9
11
class SeleniumTestCase (object ):
@@ -14,7 +16,18 @@ class SeleniumTestCase(object):
14
16
def setup (self , request ):
15
17
"""Sets up attributes that should be accessible to all test cases."""
16
18
17
- # We repeat each test for each webdriver configuration
19
+ # Repeat each test for each webdriver configuration
18
20
webdriver_cls = WEBDRIVERS [request .param ]
19
21
self .driver = webdriver_cls ()
20
22
23
+ def open (self , url ):
24
+ """Open the resource specified by `url`.
25
+ If an absolute URL is specified (like 'http://codebender.cc') we
26
+ use that URL. Otherwise the resource is relative to `BASE_URL` in
27
+ `codebender_testing.config`.
28
+ """
29
+ if re .match (".+?://^" , url ):
30
+ return self .driver .get (url )
31
+ else :
32
+ return self .driver .get ("%s/%s" % (BASE_URL , url ))
33
+
Original file line number Diff line number Diff line change 4
4
class TestHome (SeleniumTestCase ):
5
5
6
6
def test_navigate_home (self ):
7
- self .driver . get ( "http://localhost " )
7
+ self .open ( "/ " )
8
8
assert "Codebender" in self .driver .title
9
9
You can’t perform that action at this time.
0 commit comments