• Forums
    • Public Forums
      • Community Connect
      • Dynatrace
        • Dynatrace Open Q&A
      • Application Monitoring & UEM
        • AppMon & UEM Open Q&A
      • Network Application Monitoring
        • NAM Open Q&A
  • Home /
  • Public Forums /
  • Application Monitoring & UEM /
  • AppMon & UEM Open Q&A /
avatar image
Question by Matt J. · Sep 19, 2018 at 08:58 PM · appmon extensions plugins appmon 7 7.1 continuous delivery test automation

How do we add timers to Selenium - Web Driver?

The online docs I found all seem to reference older material for the deprecated Browser Agent and the dynaTrace Selenium Runner / dynaTrace Selenium Helper. None of this appears to be relevant as we are using Selenium / Web Driver scripts and UEM has replaced the browser agent.

Essentially what we are trying to do is what the below article states around "timers" but with our particular config.

https://community.dynatrace.com/community/display/PUB/How+to+include+dynaTrace+in+your+Selenium+Tests

Comment

People who like this

0 Show 1
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

avatar image Brian L. · Sep 20, 2018 at 01:22 PM 0
Share

Parallel to this - anyone know how to add the Dynatrace headers to Selenium / Web Driver scripts aka https://www.dynatrace.com/support/doc/appmon/shortlink/id_integration_with_web_load_testing_and_monitoring_tools#request-header

5 Replies

  • Sort: 
  • Most voted
  • Newest
  • Oldest
avatar image

Answer by Heather M. · Sep 25, 2018 at 02:57 PM

Hi Sonja, here is the console output from the Jenkins job...again, if I remove the second test, it connects to the REST interface on the first try.

...

End DYNATRACE SESSION::: e2301957-ee20-4251-9bba-128799886a3d
Dynatrace AppMon Plugin - build tear down...
Finishing test run with ID=e2301957-ee20-4251-9bba-128799886a3d
Sleeping for the configured delay of 60 seconds before retrieving test run data from Dynatrace Server...
Connecting to Dynatrace Server REST interface... (ID=e2301957-ee20-4251-9bba-128799886a3d)
Sleeping for the configured delay of 60 seconds before retrieving test run data from Dynatrace Server... re-try 1 out of 4
Connecting to Dynatrace Server REST interface... (ID=e2301957-ee20-4251-9bba-128799886a3d)
Sleeping for the configured delay of 60 seconds before retrieving test run data from Dynatrace Server... re-try 2 out of 4
Connecting to Dynatrace Server REST interface... (ID=e2301957-ee20-4251-9bba-128799886a3d)
Sleeping for the configured delay of 60 seconds before retrieving test run data from Dynatrace Server... re-try 3 out of 4
Connecting to Dynatrace Server REST interface... (ID=e2301957-ee20-4251-9bba-128799886a3d)
Sleeping for the configured delay of 60 seconds before retrieving test run data from Dynatrace Server... re-try 4 out of 4
Connecting to Dynatrace Server REST interface... (ID=e2301957-ee20-4251-9bba-128799886a3d)
Report summary: {Failed=0, Degraded=0, Volatile=0, Improved=0, Passed=1}.
Finished: SUCCESS

Comment

People who like this

0 Show 1 · Share
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

avatar image Sonja C. ♦ · Sep 26, 2018 at 06:37 AM 0
Share

It looks to me like the AppMon server needs more time to process the data - on the last retry, we see that the first test (Passed=1) has been analyzed but the second hasn't yet been processed.

I would try to augment the delay for fetching the data on Jenkins. If I remember correctly, two minutes should be enough.

avatar image

Answer by Heather M. · Sep 24, 2018 at 07:54 PM

Hi Sonja! Matt and I are working on this together. So per your last comment, I modified our selenium script to do the following:

1. open the browser

2. set the DT_TESTRUNID

3. For the first "transaction" of the test, defined as some functionality in the UI

(1) set the DT_TESTNAME using js.executeScript("sessionStorage.DT_TESTNAME = \"first Test\";");

(2) do the actual test stuff

(3) end the visit using js.executeScript("dynaTrace.endVisit();");

4. For the second "transaction" of the test, defined as some functionality in the UI

(1) set the DT_TESTNAME using js.executeScript("sessionStorage.DT_TESTNAME = \"Second Test\";");

(2) do the actual test stuff

(3) end the visit using js.executeScript("dynaTrace.endVisit();");

5. Close the browser.

When I only run with one transaction, say first Test, and remark out the second transaction, everything works OK, the REST calls at the end of the Jenkins job are successful, and the test automation dashlet is updated. When I call both tests, and set the testname and end the visit for each before closing the browser, the REST calls fail, and the test automation dashlet does not update.

Am I to draw the conclusion that I cannot have a test run broken down into component functionality pieces, as Matt described - results for Login, results for Add Item, results for LogOut - in a single test? Or are we just doing something wrong?

Thanks!!

Here is our Selenium script:

package dyna;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.FluentWait;

public class Main {
	static WebDriver _Browser ;
	static JavascriptExecutor js;
	static String _DynaTestName;
	static String dynaTstId;
	
	public static void main(String[] args) throws Exception{
	/***********************************************************************
         * Get everything started for the first time
         **********************************************************************/
		String ChromDriverDirectory = ".\\Package\\BrowserDrivers\\Chrome Driver			\\chromedriver.exe";
		DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
		System.setProperty("webdriver.chrome.driver", ChromDriverDirectory);
		_Browser = new ChromeDriver(chromeCapabilities);
		_Browser.get("http://10.42.178.0:8180/");
		js = (JavascriptExecutor) _Browser;
		
		InitializeDynatrace();
		
		/**********************************************************************
	     	* Run the first test
	     	* 1. Set the DynaTestName
	     	* 2. Start the test (transaction)
	     	* 3. End the transaction
	     	**********************************************************************/
		SetDynatraceTestName("EditAmountTest");
		EditAmountTest();
		endDynatraceVisit();
		
		/***********************************************************************
	     	* Run the second test
	     	* 1. Set the DynaTestName
	     	* 2. Start the test (transaction)
	     	* 3. End the transaction
	     	***********************************************************************/
		SetDynatraceTestName("OriginalUITest");
		OriginalUITest();
		endDynatraceVisit();
		
		/***********************************************************************
	     	* Close the browser down, we're done
	     	***********************************************************************/
		_Browser.close();
	}

	/*******************************************************************************
     	* Edit Amount test
     	*******************************************************************************/
	public static void EditAmountTest() throws Exception {
		// TEST HERE
	}
	
	/*******************************************************************************
     	* Original test
     	*******************************************************************************/
	public static void OriginalUITest() throws Exception {
		// SECOND TEST HERE
	}
	
	public static void InitializeDynatrace(){
		dynaTstId =System.getenv("dtTestrunID");
		try {
		   if(dynaTstId !=null) {
  		   System.out.println("DynatraceID:::"+dynaTstId);
    		   js.executeScript("sessionStorage.DT_TESTRUNID = \""+dynaTstId+"\";");
		}
		}catch(Exception e) {
		   System.out.println("Dynatrace Exception "+e.getMessage());
		   }
		}
		
	public static void SetDynatraceTestName(String testname){
		js.executeScript("sessionStorage.DT_TESTNAME = \""+testname+"\";");    	
	}	
	
	public static void endDynatraceVisit(){
		try {
		if(dynaTstId !=null) {
		  js.executeScript("dynaTrace.endVisit();");
		  System.out.println("End DYNATRACE SESSION::: "+dynaTstId);
	    	}
		} catch (Exception e) {
		  System.out.println("ERROR DYNATRACE END SESSION::: "+e.getMessage());
		  }
		}
Comment

People who like this

0 Show 1 · Share
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

avatar image Sonja C. ♦ · Sep 25, 2018 at 06:17 AM 0
Share

Hi! what do you mean by the REST calls fail? which result do you get back? also did you wait a little bit longer? It takes some time for the visits to be fully processed.

Typically, the recommended integration scenario will be to have only 1 visit for the whole test - and to look at the user actions for specific test steps. But the approach you are trying should also work. The only limitation that comes to my mind is that the second visit will only be started after your applications is making server side calls.

avatar image

Answer by Sonja C. · Sep 24, 2018 at 06:17 AM

one UEM visit = one test (that will show up individually in this dashlet). To achieve what you what, you need to programatically end the visit:

js.executeScript("dynaTrace.endVisit();");

And then re-set another test name:

js.executeScript("sessionStorage.DT_TESTNAME = \"myTest\";");

See also "Tag the UEM visit as a test" in the documentation: https://www.dynatrace.com/support/doc/appmon/conti...

Comment

People who like this

0 Show 0 · Share
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

avatar image

Answer by Matt J. · Sep 20, 2018 at 02:01 PM

OK but is there a way to define transactions within a script and have it show up in the test results dashlet? For example my test is called SELENIUM UI TEST but I was hoping to have the transactions defined so we could have a "launch" a "login" and a "search" so we have a breakdown of metrics captured for each transaction. Rather than just see a sum of DB calls and bytes received for the test, we would like to see it based on a transaction. So The "Launch" transaction made X DB calls and had Y bytes received, and the "Login" transaction made Z DB calls and had W bytes received etc. It looks like it was possible through the old way.


cpic2.png (38.5 KiB)
cusersmmjordandesktoppic2.png (38.5 KiB)
Comment

People who like this

0 Show 0 · Share
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

avatar image

Answer by Sonja C. · Sep 20, 2018 at 06:22 AM

Here is the latest documentation on integrating AppMon with Selenium (using UEM - User Experience Management & the JavaScript Agent): https://www.dynatrace.com/support/doc/appmon/conti...

Timers concept of the deprecated Browser Agent has been replaced with the JavaScript Agent / UEM visit (= test) and actions (= test steps). You can find more details on configuring the UEM action in the UEM documentation:

  • https://www.dynatrace.com/support/doc/appmon/appli...
  • Javascript ADK https://www.dynatrace.com/support/doc/appmon/integ...

Hope this helps!

Sonja

Comment

People who like this

0 Show 0 · Share
10 |2000000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

How to get started

First steps in the forum
Read Community User Guide
Best practices of using forum

NAM 2019 SP5 is available


Check the RHEL support added in the latest NAM service pack.

Learn more

LIVE WEBINAR

"Performance Clinic - Monitoring as a Self Service with Dynatrace"


JANUARY 15, 3:00 PM GMT / 10:00 AM ET

Register here

Follow this Question

Answers Answers and Comments

33 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Dynatrace Test Result Trend in Jenkins is blank despite over a dozen runs

How to configure URL Monitor for 'application/json' requests?

JMX Enhanced Monitor Plugin | Metrics received (logs) but no measures avaiable for charting

Jira Implemention with DynaTrace Appmon for Version 6.5 or Version 7

Will business transaction row counter plugin work effectively for AppMon 7.1.8?

Forum Tags

dotnet mobile monitoring load iis 6.5 kubernetes mainframe rest api dashboard framework 7.0 appmon 7 health monitoring adk log monitoring services auto-detection uem webserver test automation license web performance monitoring ios nam probe collector migration mq web services knowledge sharing reports window java hybris javascript appmon sensors good to know extensions search 6.3+ server documentation easytravel web dashboard kibana system profile purelytics docker splunk 6.1 process groups account 7.2 rest dynatrace saas spa guardian appmon administration production user actions postgresql upgrade oneagent measures security Dynatrace Managed transactionflow technologies diagnostics user session monitoring unique users continuous delivery sharing configuration alerting NGINX splitting business transaction client 6.3 installation database scheduler apache mobileapp RUM php dashlet azure purepath agent 7.1 appmonsaas messagebroker nodejs 6.2 android sensor performance warehouse
  • Forums
  • Public Forums
    • Community Connect
    • Dynatrace
      • Dynatrace Open Q&A
    • Application Monitoring & UEM
      • AppMon & UEM Open Q&A
    • Network Application Monitoring
      • NAM Open Q&A