Skip to content

Commit 96348a2

Browse files
committed
fix: merge conflicts, flake8 issues
1 parent be53047 commit 96348a2

File tree

7 files changed

+20
-43
lines changed

7 files changed

+20
-43
lines changed

autowebcompat/crawler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from selenium.common.exceptions import NoAlertPresentException, NoSuchWindowException
1+
from selenium.common.exceptions import NoAlertPresentException
2+
from selenium.common.exceptions import NoSuchWindowException
23

34

45
def close_all_windows_except_first(driver):

autowebcompat/driver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class Driver:
99

1010
def __init__(self):
11-
1211
chrome_bin, nightly_bin = get_browser_bin()
1312

1413
os.environ['PATH'] += os.pathsep + os.path.abspath('tools')

autowebcompat/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import sys
88
import threading
99

10+
from PIL import Image
1011
import keras
1112
from keras.preprocessing.image import ImageDataGenerator
1213
from keras.preprocessing.image import img_to_array
1314
from keras.preprocessing.image import load_img
14-
from tensorflow.python.client import device_lib
15-
from PIL import Image
1615
import numpy as np
16+
from tensorflow.python.client import device_lib
1717

1818

1919
def get_bugs():
@@ -237,7 +237,6 @@ def write_bounding_boxes(bounding_boxes, file_name):
237237

238238

239239
def get_browser_bin():
240-
241240
if sys.platform.startswith('linux'):
242241
chrome_bin = 'tools/chrome-linux/chrome'
243242
nightly_bin = 'tools/nightly/firefox-bin'

collect.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,53 +64,33 @@ def wait_loaded(driver):
6464
print('Continuing...')
6565

6666

67-
def get_all_attributes(driver, child):
68-
child_attributes = driver.execute_script("""
69-
let elem_attribute = {};
70-
71-
for (let i = 0; i < arguments[0].attributes.length; i++) {
72-
elem_attribute[arguments[0].attributes[i].name] = arguments[0].attributes[i].value;
73-
}
74-
return elem_attribute;
75-
""", child)
76-
77-
return child_attributes
78-
79-
80-
def get_elements_with_attributes(driver, elem_attributes, children):
81-
elems_with_same_attributes = []
82-
for child in children:
83-
child_attributes = get_all_attributes(driver, child)
84-
if child_attributes == elem_attributes:
85-
elems_with_same_attributes.append(child)
86-
return elems_with_same_attributes
87-
88-
89-
def get_elements_with_properties(driver, elem_properties, children):
90-
elems_with_same_properties = []
91-
for child in children:
92-
child_properties = get_element_properties(driver, child)
93-
if child_properties == elem_properties:
94-
elems_with_same_properties.append(child)
95-
return elems_with_same_properties
96-
97-
9867
def get_element_properties(driver, child):
9968
child_properties = driver.execute_script("""
10069
let elem_properties = {
10170
tag: '',
10271
attributes: {},
10372
};
73+
10474
for (let i = 0; i < arguments[0].attributes.length; i++) {
10575
elem_properties.attributes[arguments[0].attributes[i].name] = arguments[0].attributes[i].value;
10676
}
10777
elem_properties.tag = arguments[0].tagName;
78+
10879
return elem_properties;
10980
""", child)
11081

11182
return child_properties
11283

11384

85+
def get_elements_with_properties(driver, elem_properties, children):
86+
elems_with_same_properties = []
87+
for child in children:
88+
child_properties = get_element_properties(driver, child)
89+
if child_properties == elem_properties:
90+
elems_with_same_properties.append(child)
91+
return elems_with_same_properties
92+
93+
11494
def was_visited(current_path, visited_paths, elem_properties):
11595
current_path_elements = [element for element, _, _ in current_path]
11696
current_path_elements.append(elem_properties)

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/test_crawler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from autowebcompat.crawler import close_all_windows_except_first
1+
from autowebcompat import crawler
22
from autowebcompat.driver import Driver
33

44

@@ -17,8 +17,8 @@ def test_close_all_windows_except_first(self):
1717
self.driver.chrome.execute_script("window.open('https://google.com')")
1818
assert len(self.driver.firefox.window_handles) == 3, 'More than 3 windows are open'
1919

20-
close_all_windows_except_first(self.driver.firefox)
21-
close_all_windows_except_first(self.driver.chrome)
20+
crawler.close_all_windows_except_first(self.driver.firefox)
21+
crawler.close_all_windows_except_first(self.driver.chrome)
2222

2323
assert len(self.driver.firefox.window_handles) == 1
2424
assert len(self.driver.chrome.window_handles) == 1

tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ def test_get_browser_bin():
141141
chrome_bin, nightly_bin = utils.get_browser_bin()
142142
assert isinstance(chrome_bin, str)
143143
assert isinstance(nightly_bin, str)
144-
assert os.path.exists(os.path.abspath('./') + '/' + chrome_bin)
145-
assert os.path.exists(os.path.abspath('./') + '/' + nightly_bin)
144+
assert os.path.exists(os.path.join(os.path.abspath('./'), chrome_bin))
145+
assert os.path.exists(os.path.join(os.path.abspath('./'), nightly_bin))
146146

147147

148148
def test_create_file_name():

0 commit comments

Comments
 (0)