Skip to content

Brython integration and more #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions examples/offline_examples/demo_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ <h3>Automation Practice</h3>
<tr>
<td>Input Slider Control:</td>
<td>
<input type="range" min="0" max="4" step="1"
id="mySlider" name="sliderName" value="2"
<input type="range" min="0" max="100" step="10"
id="mySlider" name="sliderName" value="50"
style="width: 88%;" class="slider"
onclick="sliderFunction1()"
onchange="sliderFunction1()"
Expand Down Expand Up @@ -439,26 +439,8 @@ <h3>Automation Practice</h3>
var s = document.getElementById("mySlider");
var p = document.getElementById("progressBar");
var pl = document.getElementById("progressLabel");
if (s.value == "0") {
p.value = "0";
pl.textContent = "Progress Bar: (0%)";
}
if (s.value == "1") {
p.value = "25";
pl.textContent = "Progress Bar: (25%)";
}
if (s.value == "2") {
p.value = "50";
pl.textContent = "Progress Bar: (50%)";
}
if (s.value == "3") {
p.value = "75";
pl.textContent = "Progress Bar: (75%)";
}
if (s.value == "4") {
p.value = "100";
pl.textContent = "Progress Bar: (100%)";
}
p.value = s.value;
pl.textContent = "Progress Bar: (" + p.value + "%)";
}
</script>
<script>
Expand Down
21 changes: 10 additions & 11 deletions examples/offline_examples/test_demo_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from selenium.webdriver.common.keys import Keys
from seleniumbase import BaseCase


Expand All @@ -19,22 +18,25 @@ def test_demo_page(self):
self.update_text("textarea.area1", "Testing Time!\n")
self.update_text('[name="preText2"]', "Typing Text!")

# Verify that a hover dropdown link changes page text
self.assert_text("Automation Practice", "h3")
self.hover_and_click("#myDropdown", "#dropOption2")
self.assert_text("Link Two Selected", "h3")

# Verify that a button click changes text on the page
self.assert_text("This Text is Green", "#pText")
self.click("#myButton")
self.assert_text("This Text is Purple", "#pText")

# Verify that the hover dropdown option changes text
self.assert_text("Automation Practice", "h3")
self.hover_and_click("#myDropdown", "#dropOption2")
self.assert_text("Link Two Selected", "h3")
# Assert that the given SVG is visible on the page
self.assert_element('svg[name="svgName"]')

# Verify that moving a "slider" updates a progrss bar
# Verify that a slider control updates a progrss bar
self.assert_element('progress[value="50"]')
self.send_keys("#myslider", Keys.RIGHT + Keys.RIGHT)
self.press_right_arrow("#myslider", times=5)
self.assert_element('progress[value="100"]')

# Verify that the "select" option updates a meter bar
# Verify that a "select" option updates a meter bar
self.assert_element('meter[value="0.25"]')
self.select_option_by_text("#mySelect", "Set to 75%")
self.assert_element('meter[value="0.75"]')
Expand All @@ -61,8 +63,5 @@ def test_demo_page(self):
self.click("#radioButton2")
self.assert_true(self.is_selected("#radioButton2"))

# Assert that the SVG is visible on the page
self.assert_element('svg[name="svgName"]')

# Assert the title of the current web page
self.assert_title("Web Testing Page")
12 changes: 12 additions & 0 deletions examples/test_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from seleniumbase import BaseCase


class MyTestClass(BaseCase):

def test_user_agent(self):
self.open('http://whatsmyuseragent.org/')
user_agent = self.get_text(".user-agent p")
print("\n\nUser-Agent:\n%s\n" % user_agent)
print(self.get_text(".ip-address p"))
print("\nThe browser will close automatically in 7 seconds...")
self.sleep(7)
3 changes: 1 addition & 2 deletions examples/user_agent_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time
from seleniumbase import BaseCase


Expand All @@ -11,4 +10,4 @@ def test_user_agent(self):
print("Displaying User-Agent Info:")
print(self.get_text("#useragent"))
print("\nThe browser will close automatically in 7 seconds...")
time.sleep(7)
self.sleep(7)
8 changes: 8 additions & 0 deletions help_docs/method_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ self.highlight_update_text(selector, new_value, by=By.CSS_SELECTOR, loops=3, scr

self.highlight(selector, by=By.CSS_SELECTOR, loops=4, scroll=True)

self.press_up_arrow(selector="html", times=1, by=By.CSS_SELECTOR)

self.press_down_arrow(selector="html", times=1, by=By.CSS_SELECTOR)

self.press_left_arrow(selector="html", times=1, by=By.CSS_SELECTOR)

self.press_right_arrow(selector="html", times=1, by=By.CSS_SELECTOR)

self.scroll_to(selector, by=By.CSS_SELECTOR)

self.slow_scroll_to(selector, by=By.CSS_SELECTOR)
Expand Down
21 changes: 21 additions & 0 deletions integrations/brython/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Getting Started with Brython

* Brython was designed for replacing JavaScript with Python.
* This tutorial will show you how to get started quickly.

### 1. Get a web server up and running:

```bash
python -m http.server
```
(You can always stop the server by using ``CTRL-C``.)

### 2. Navigate to [http://localhost:8000/](http://localhost:8000/)

Now click on the examples to see Brython in action.

### 3. For more info, see the following:

* https://brython.info/
* https://pypi.org/project/brython/
* https://github.com/brython-dev/brython
44 changes: 44 additions & 0 deletions integrations/brython/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><meta charset="iso-8859-1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/css/bootstrap.min.css" />
<style>
body,td,th,h1{
font-family:sans-serif;
}
td,h1 {
border-style:solid;
border-width: 6px 6px 6px 6px;
border-color: #FFF;
padding: 8px;
}
th {
border-style: none;
border-width: 6px;
border-color: #FFF;
background-color: #91E7B4;
padding: 8px;
}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js"></script>
</head>
<body onload="brython()">
<table>
<tbody>
<h1 id="topHeader"></h1>
<td>
<th>
<h2>
<a href="library.html">Library / Indexed DB Example</a>
</h2>
</th>
</td>
</tbody>
</table>
<script type="text/python">
import index
index.setup_page()
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions integrations/brython/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from browser import document


def setup_page():
document['topHeader'].textContent = "Brython Examples:"
Loading