Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

dc-app-performance-toolkit: debug selenium tests and solve insecure ssl certificate error

Hello!

In this article we will talk about Atlassian tool called dc-app-performance-toolkit. This tool helps you to performance test your Jira, Confluence and Bitbucket instances.

I wrote a couple of articles about this toolkit.

The toolkit consists of Jmeter and Selenium tests.

In this article I would like to give you a hint how you can understand what is going wrong in Selenium tests and how to solve the insecure SSL certificate error.

Problem

I ran dc-app-performance-toolkit on a Bitbucket instance and during the run I could see many errors with Selenium scripts:

Screenshot 2020-09-10 at 11.02.48.png

As you can see I have 100% errors with selenium_login script with the NoSuchEle error.

How to understand what went wrong?

Analyze

I opened the selenium.err file and found many lines like this:

Action: test_0_selenium_a_login, Error: bitbucket_webdriver = <selenium.webdriver.chrome.webdriver.WebDriver (session="e369b1efa8c2794638560ae68246409a")>
bitbucket_datasets = {'password': 'dcapt-perf-user-hsyjq', 'project_key': 'PRJ-10009', 'projects': [['FORKS-1', '2987'], ['PRJ-1', '5'], ['...RJ-100', '101'], ['PRJ-1000', '1001'], ['PRJ-10000', '11401'], ...], 'pull_request_branch_from': 'perf-branch-24', ...}
bitbucket_screen_shots = None

def test_0_selenium_a_login(bitbucket_webdriver, bitbucket_datasets, bitbucket_screen_shots):
> modules.login(bitbucket_webdriver, bitbucket_datasets)

selenium_ui/bitbucket_ui.py:7:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
selenium_ui/bitbucket/modules.py:41: in login
measure()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

@functools.wraps(func)
def wrapper():
if LOGIN_ACTION_NAME in interaction:
globals.login_failed = False
if globals.login_failed:
pytest.skip(f"login is failed")
start = time.time()
error_msg = 'Success'
full_exception = ''
try:
func()
success = True
except Exception:
success = False
# https://docs.python.org/2/library/sys.html#sys.exc_info
exc_type, full_exception = sys.exc_info()[:2]
error_msg = f"Failed measure: {interaction} - {exc_type.__name__}"
end = time.time()
timing = str(int((end - start) * 1000))

with open(selenium_results_file, "a+") as jtl_file:
timestamp = round(time.time() * 1000)
jtl_file.write(f"{timestamp},{timing},{interaction},,{error_msg},,{success},0,0,0,0,,0\n")

print(f"{timestamp},{timing},{interaction},{error_msg},{success}")

if not success:
if LOGIN_ACTION_NAME in interaction:
globals.login_failed = True
> raise Exception(error_msg, full_exception)
E Exception: ('Failed measure: selenium_login - Exception', Exception('Failed measure: selenium_login:open_login_page - NoSuchElementException', NoSuchElementException('no such element: Unable to locate element: {"method":"css selector","selector":"[id="product-version"]"}\n (Session info: headless chrome=85.0.4183.102)', None, None)))

From these lines I can see that Selenium can not locate and html element with id="product-version". But why?

Ok. Let's have a look at the folder with screenshots for Selenium errors.

I found many files with the following contents.

For the html code for the page I have:

<html><head></head><body></body></html>

And for the screenshot I have a blank screen.

Hmm. Nothing has become clearer.

Set WEBDRIVER_VISIBLE to True

I do not understand why I have the error. I need to see how Selenium works with my browser myself. And there is a parameter in the bitbucket.yml file (the same true for jira.yml and confluence.yml) called WEBDRIVER_VISIBLE. By default the value of this parameter is False, but if you set it to True then you will see your browser during Selenium test execution.

I set this parameter to True and here is what I saw:

Screenshot 2020-09-10 at 11.05.12.png

Now everything is clear. Selenium thinks that the first page will be the Log In page but instead we have a error. Selenium tries to find the required element and can not find and throws an error as the result.

Well, now we understand what is going on. Let's fix it.

Fix insecure SSL certificate error

The webdriver is set up in the app/selenium_ui/conftest.py file:

    def driver_init():
chrome_options = Options()
if not app_settings.webdriver_visible:
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size={},{}".format(SCREEN_WIDTH, SCREEN_HEIGHT))
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument('ignore-certificate-errors')
driver.app_settings = app_settings
return driver

All we have to do is to add the following line:

chrome_options.add_argument('ignore-certificate-errors')

This line will tell Selenium to run Chrome without checking SSL certificates. Here is our final the driver_init method:

   def driver_init():
chrome_options = Options()
if not app_settings.webdriver_visible:
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size={},{}".format(SCREEN_WIDTH, SCREEN_HEIGHT))
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument('ignore-certificate-errors')
driver = Chrome(options=chrome_options)
driver.app_settings = app_settings
return driver

Now Selenium tests work.

1 comment

Mohammed Amine Community Leader Jun 04, 2021

Very interesting article

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

456 views 5 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you