pip install
, so if your tests always install dependencies before running tests, you'll see a big improvement: See seleniumbase/SeleniumBase#1406 (a significant savings)--demo_sleep=SEC
(It uses the demo_mode timeout for slow_mode)
behave
methods like before_all
, before_feature
, before_scenario
, etc, at the end of this file: https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/behave/behave_sb.pypytest-html
report is a separate plugin with a separate maintainer. There may be a few possible workarounds, such as using print()
commands to output the data as the test runs.self.save_data_as(data, file_name, destination_folder=None)
to save that data to a file.
Hi @mdmintz ,
We want to access button element that contains text in its child span, having issues due to there s no id that we can access to that button. Is there any way?
We can actually get the span, but can not access to the parent button and cant click on it, snippet attached
:contains("TEXT")
selector:from seleniumbase import BaseCase
from seleniumwire import webdriver # the selenium-wire webdriver
class WireTestCase(BaseCase):
def get_new_driver(self, *args, **kwargs):
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
return webdriver.Chrome(options=options)
def test_simple(self):
self.open("https://seleniumbase.io/demo_page")
for request in self.driver.requests:
print(request.url)
@EvgeniiBiriukov See if https://stackoverflow.com/a/31482681/7058266 works for you.
Michael, thanks! It works correctly.
Hi there! I don't know if I've said enough previously but thank you so much for your help working through things. Can you help me figure out capabilities changes with selenium 4? I use Gridlastic (selenium grid cloud provider) and with selenium 4, they are looking for this to enable video recording:
{
"gridlastic:options":
{
"video": true,
}
}
I tried adding a caps.json file to test setting that, and it got added as this (cut out some lines for brevity):
{
"cloud:options":
{
"gridlastic:options":
{
"video": true,
}
}
}
Is there a way to currently pass in capabilities that don't get put under cloud:options? Or can you add functionality that checks the caps provided to SB, and if it is in the format of {string}:{string} pass them straight through without putting it under cloud:options?
See the note "(check with your cloud vendor for the appropriate prefix)" on this page: https://www.selenium.dev/documentation/webdriver/getting\_started/upgrade\_to\_selenium\_4/#capabilities
--cap_file=CAP_FILE.py
I tried with a similar cap file as suggested, but actually, if I understand these lines correctly, then seleniumbase will nest all capabilities provided under cloud:options
except for the ones handled specifically here (selenoid:options
, screenResolution
, version
, platform
). These handled ones get put at the top level, instead of under cloud:options
. I was poking at browser_launcher on how it could be handled differently and came up with this (L1, L13-14, L29-31 here):
custom_options = {}
for key in desired_caps.keys():
capabilities[key] = desired_caps[key]
if key == "selenoid:options":
selenoid = True
selenoid_options = desired_caps[key]
elif key == "screenResolution":
screen_resolution = desired_caps[key]
elif key == "version" or key == "browserVersion":
browser_version = desired_caps[key]
elif key == "platform" or key == "platformName":
platform_name = desired_caps[key]
elif re.match("[a-zA-Z0-9]*:[a-zA-Z0-9]*", key):
custom_options[key] = desired_caps[key]
if selenium4:
chrome_options.set_capability("cloud:options", capabilities)
if selenoid:
snops = selenoid_options
chrome_options.set_capability("selenoid:options", snops)
if screen_resolution:
scres = screen_resolution
chrome_options.set_capability("screenResolution", scres)
if browser_version:
br_vers = browser_version
chrome_options.set_capability("browserVersion", br_vers)
if platform_name:
plat_name = platform_name
chrome_options.set_capability("platformName", plat_name)
if custom_options:
for key in custom_options:
chrome_options.set_capability(key, custom_options[key])
open to your thoughts - this will handle multiple custom capabilities (meaning a cap that is string:string
) should I submit a PR?
flake8
. If everything's good, I'll make a release for this. I'm working on a few big things, such as seleniumbase/SeleniumBase#1440