-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c41735f
commit 3976f3c
Showing
1 changed file
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 1,56 @@ | ||
# BrowserQuery | ||
# BrowserQuery: Streamline Selenium with jQuery | ||
|
||
Use JQuery on selenium drivers. | ||
Enhance your Selenium-driven web automation tasks with **BrowserQuery**, a Python package that empowers you to use jQuery effortlessly. This straightforward yet robust package simplifies the execution of jQuery scripts and includes built-in utility methods. | ||
|
||
A simple, yet powerful package to execute Jquery while working on selenium drivers. It also comes built in with some utility methods built in. | ||
# Installation | ||
|
||
|
||
# Install | ||
Get started quickly by installing **BrowserQuery** from PyPI: | ||
|
||
```bash | ||
pip install browserjquery | ||
``` | ||
|
||
# Usage | ||
|
||
Here's how you can harness the power of **BrowserQuery** in your Selenium scripts: | ||
|
||
```python | ||
import time | ||
import time | ||
from selenium.webdriver import Chrome | ||
from browserjquery import BrowserJQuery | ||
|
||
from selenium.webdriver import Chrome | ||
from browserjquery import BrowserJQuery | ||
# Initialize a Selenium driver | ||
driver = Chrome() | ||
|
||
driver = Chrome() | ||
# Navigate to a website | ||
driver.get("https://www.yahoo.com") | ||
|
||
driver.get("https://www.yahoo.com") | ||
# Pause to allow page loading (you can adjust the duration) | ||
time.sleep(10) | ||
|
||
time.sleep(10) | ||
# Create a jQuery object for the driver | ||
jquery = BrowserJQuery(driver) | ||
|
||
# create Jquery object | ||
jquery = BrowserJQuery(driver) | ||
# Execute a jQuery script | ||
jquery.execute("""return $("div.stream-item")""") | ||
|
||
# execute script | ||
jquery.execute("""return $("div.stream-item")""") | ||
# Use the jQuery object to find and select items | ||
stream = jquery(".stream-item") | ||
|
||
# call the object as a method to find/select items | ||
stream = jquery(".stream-item") | ||
# Access methods and attributes of the jQuery object | ||
print(jquery.document) | ||
|
||
# call methods/attributes off of the object | ||
print(jquery.document) | ||
# Find elements within the selected items | ||
print(jquery.find(".stream-item a")) | ||
|
||
print(jquery.find(".stream-item a")) | ||
# Find elements with specific text | ||
print(jquery.find_elements_with_text("Hello")) | ||
|
||
print(jquery.find_elements_with_text("Hello")) | ||
print(jquery.find_elements_with_text("Hello", element=stream[0])) | ||
# Find elements with specific text within a specific element | ||
print(jquery.find_elements_with_text("Hello", element=stream[0])) | ||
|
||
print(jquery.parent(stream[0])) | ||
# Get the parent element of a selected item | ||
print(jquery.parent(stream[0])) | ||
``` | ||
|
||
With **BrowserQuery**, you can effortlessly integrate jQuery into your Selenium workflows, making web automation more efficient and powerful. |