-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug in the adminbot by adding delays when clicks cause the vi…
…ew to change in PwnedHub 2.0.
- Loading branch information
1 parent
8638f77
commit cdc9643
Showing
1 changed file
with
6 additions
and
2 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,7 +1,8 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.firefox.options import Options as FirefoxOptions | ||
from selenium.webdriver.firefox.service import Service as FirefoxService | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.webdriver.support.ui import Select, WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
from selenium.webdriver.common.keys import Keys | ||
import glob | ||
import os.path | ||
|
@@ -35,6 +36,8 @@ def __init__(self, driver, name): | |
def debug(self, s): | ||
print(f"[{self.__class__.__name__}] [{self.name}] [{self.driver.current_url}] {s}") | ||
|
||
def wait_until_url(self, url): | ||
WebDriverWait(self.driver, 10).until(EC.url_to_be(url)) | ||
|
||
class HubBot(BaseBot): | ||
|
||
|
@@ -103,14 +106,14 @@ def log_in(self, email): | |
self.debug('Logging in.') | ||
login_button = self.driver.find_element('xpath', '//input[@type="button" and @value="Log me in please."]') | ||
login_button.click() | ||
self.wait_until_url('http://test.pwnedhub.com/#/login/passwordless') | ||
|
||
self.debug('Fetching the Passwordless Authentication code.') | ||
inbox_url = 'http://admin.pwnedhub.com/inbox/[email protected]' | ||
import urllib.request | ||
contents = urllib.request.urlopen(inbox_url).read().decode() | ||
match = re.search(r'<br><br>(\d{6})<br><br>', contents) | ||
code = match.group(1) | ||
print(f"\n\n{code}\n\n") | ||
|
||
self.debug('Setting the inputs.') | ||
code_input = self.driver.find_element('name', 'code') | ||
|
@@ -119,6 +122,7 @@ def log_in(self, email): | |
self.debug('Submitting the Passwordless Authentication code.') | ||
code_button = self.driver.find_element('xpath', '//input[@type="button" and @value="Yes, it\'s really me."]') | ||
code_button.click() | ||
self.wait_until_url('http://test.pwnedhub.com/#/admin/users') | ||
|
||
def send_private_message(self, room_id, message): | ||
self.debug('Visiting the Messaging view.') | ||
|