Skip to content

Commit 25f65c7

Browse files
committed
update python sample and readme
1 parent f395ad7 commit 25f65c7

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

staging/selenium/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,10 @@ Let's run a quick Selenium job to validate our setup.
9696

9797
#### Setup Python Environment
9898

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.
100100

101101
```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
110103
```
111104

112105
Once inside, we need to install the Selenium library
@@ -127,14 +120,17 @@ And paste in the contents of selenium-test.py.
127120

128121
```python
129122
from selenium import webdriver
130-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
131123

132124
def check_browser(browser):
125+
if browser == "CHROME":
126+
options = webdriver.ChromeOptions()
127+
elif browser == "FIREFOX":
128+
options = webdriver.FirefoxOptions()
133129
driver = webdriver.Remote(
134130
command_executor='http://selenium-hub:4444/wd/hub',
135-
desired_capabilities=getattr(DesiredCapabilities, browser)
131+
options=options
136132
)
137-
driver.get("http://google.com")
133+
driver.get("http://www.google.com")
138134
assert "google" in driver.page_source
139135
driver.quit()
140136
print("Browser %s checks out!" % browser)
@@ -190,7 +186,6 @@ kubectl delete deployment selenium-node-chrome
190186
kubectl delete deployment selenium-node-firefox
191187
kubectl delete deployment selenium-python
192188
kubectl delete svc selenium-hub
193-
kubectl delete svc selenium-hub-external
194189
```
195190

196191

staging/selenium/selenium-test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
# limitations under the License.
1616

1717
from selenium import webdriver
18-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
1918

2019
def check_browser(browser):
20+
if browser == "CHROME":
21+
options = webdriver.ChromeOptions()
22+
elif browser == "FIREFOX":
23+
options = webdriver.FirefoxOptions()
2124
driver = webdriver.Remote(
2225
command_executor='http://selenium-hub:4444/wd/hub',
23-
desired_capabilities=getattr(DesiredCapabilities, browser)
26+
options=options
2427
)
25-
driver.get("http://google.com")
28+
driver.get("http://www.google.com")
2629
assert "google" in driver.page_source
2730
driver.quit()
2831
print("Browser %s checks out!" % browser)

0 commit comments

Comments
 (0)