Skip to content

Commit

Permalink
[py] Handle first/always match better when it hits lists/dicts. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jul 15, 2021
1 parent 7afecdc commit 2e53853
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
NoSuchCookieException)
from selenium.webdriver.common.by import By
from selenium.webdriver.common.options import BaseOptions
from selenium.webdriver.common.print_page_options import PrintOptions
from selenium.webdriver.common.timeouts import Timeouts
from selenium.webdriver.common.html5.application_cache import ApplicationCache
from selenium.webdriver.support.relative_locator import RelativeBy
from selenium.webdriver.common.print_page_options import PrintOptions


_W3C_CAPABILITY_NAMES = frozenset([
Expand All @@ -70,6 +70,7 @@
'platform': 'platformName'
}


devtools = None


Expand Down Expand Up @@ -126,15 +127,23 @@ def create_matches(options: List[BaseOptions]) -> Dict:
for opt in options:
opts.append(opt.to_capabilities())
opts_size = len(opts)
samesies = set()
samesies = {}

# Can not use bitwise operations on the dicts or lists due to
# https://bugs.python.org/issue38210
for i in range(opts_size):
min_index = i
if i + 1 < opts_size:
samesies.update(opts[min_index].items() & opts[i + 1].items())
first_keys = opts[min_index].keys()

for kys in first_keys:
if kys in opts[i + 1].keys():
if opts[min_index][kys] == opts[i + 1][kys]:
samesies.update({kys: opts[min_index][kys]})

always = {}
for i in samesies:
always[i[0]] = i[1]
for k, v in samesies.items():
always[k] = v

for i in opts:
for k in always.keys():
Expand Down

0 comments on commit 2e53853

Please sign in to comment.