@@ -96,17 +96,10 @@ Let's run a quick Selenium job to validate our setup.
96
96
97
97
#### Setup Python Environment
98
98
99
- First, we need to start a python container that we can attach to.
99
+ First, we need to start a python container that we can attach to, then get inside this container .
100
100
101
101
``` console
102
- kubectl run selenium-python --image=google/python-hello
103
- ```
104
-
105
- Next, we need to get inside this container.
106
-
107
- ``` console
108
- export PODNAME=`kubectl get pods --selector="run=selenium-python" --output=template --template="{{with index .items 0}}{{.metadata.name}}{{end}}"`
109
- kubectl exec --stdin=true --tty=true $PODNAME bash
102
+ kubectl run selenium-python --tty -i --image=python:slim bash
110
103
```
111
104
112
105
Once inside, we need to install the Selenium library
@@ -127,14 +120,17 @@ And paste in the contents of selenium-test.py.
127
120
128
121
``` python
129
122
from selenium import webdriver
130
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
131
123
132
124
def check_browser (browser ):
125
+ if browser == " CHROME" :
126
+ options = webdriver.ChromeOptions()
127
+ elif browser == " FIREFOX" :
128
+ options = webdriver.FirefoxOptions()
133
129
driver = webdriver.Remote(
134
130
command_executor = ' http://selenium-hub:4444/wd/hub' ,
135
- desired_capabilities = getattr (DesiredCapabilities, browser)
131
+ options = options
136
132
)
137
- driver.get(" http://google.com" )
133
+ driver.get(" http://www. google.com" )
138
134
assert " google" in driver.page_source
139
135
driver.quit()
140
136
print (" Browser %s checks out!" % browser)
@@ -190,7 +186,6 @@ kubectl delete deployment selenium-node-chrome
190
186
kubectl delete deployment selenium-node-firefox
191
187
kubectl delete deployment selenium-python
192
188
kubectl delete svc selenium-hub
193
- kubectl delete svc selenium-hub-external
194
189
```
195
190
196
191
0 commit comments