-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
328227a
commit d81c442
Showing
2 changed files
with
46 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.chrome.service import Service | ||
from webdriver_manager.chrome import ChromeDriverManager | ||
from selenium.common.exceptions import NoSuchElementException | ||
|
||
from time import sleep | ||
from selenium.webdriver.remote.webelement import WebElement | ||
|
||
|
||
|
||
|
||
|
||
# Configure the necessary command-line option | ||
options = webdriver.ChromeOptions() | ||
# Note that you will need to download the build of the extension and put the path to the dist folder | ||
options.add_argument(r'--load-extension=path\to\dist_folder_of_extension') | ||
|
||
# installing chromedriver | ||
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options = options) | ||
sleep(2) | ||
# add a hardcoded url leading to a particular tweet which you are using for testing | ||
driver.get('your url here') | ||
sleep(5) | ||
# Check if the extension worked and log the result. | ||
try: | ||
# logic to check if the slur is replaced | ||
ele = driver.find_element('xpath','//span[contains(text(),"▓")]') | ||
print('Success! :-)') | ||
# if no such span is present where the character - ▓ - is not present then the Failure message will show up | ||
# Note that this will return success if the tweet by default contains the replacement character | ||
except NoSuchElementException: | ||
print('Failure! :-(') | ||
finally: | ||
''' Clean up. ''' | ||
driver.quit() |