Unclear on testability of Gojs based on existing replies in form.nwoods.com

There are various questions and answers on the testability of GoJs with automation tools like Selenium.

Sorry that for a person trying to look at it its very unclear.

  1. Can goJS diagrams be accessed via DOM rendering post application deployment and then navigating to that page using selenium?
  2. If Selenium can access only Dom, Canvas tags does not have any Gojs elements. So let us say that we need to access gojd elements/nodes using javascript …
  • Purely after diagrams are loaded in browser, and we see the HTML DoM in chrome,
  • Can we access GoJS nodes using javascript ?
  • Can someone provide a base js code for that from start to finish? with some public page pls.

Especially Walter has been unclear on this.

etc

this code … is it actual code ?

Yes, you can find and examine nodes and links in GoJS diagrams usingJavaScript.

Given the HTML Div Element, you can get the Diagram instance via go.Diagram.fromDiv(aDiv).

Once you have a Diagram you can look at its properties and call its methods: Diagram | GoJS API

A complete example: Simulating Input Events

We are not familiar with Selenium, but many people have posted in this forum about it.

@walter … qq … go.Diagram.fromDiv(aDiv)

what is ‘go’ … do i need to install gojs and import Gojs?

  • So you are saying that we need to automate using application and deploy as server ? and not after the application is loaded?
  • OR
  • You are saying we can in console of chrome use javascript to do that ? after opening that page [without that code you gave me ? The code you gave me involved deploying that html page as an application] . What I am saying is after the app is deployed as webserver , without your code. Can I navigate to that page and then try to use javascript in console ?

If the page is already showing a diagram in some DIV element, then clearly the GoJS code has already been loaded. Whether or not “window.go” evaluates to the GoJS namespace depends on how the app was packaged, which we have no control over.

If the page is already showing a diagram in some DIV element, then clearly the GoJS code has already been loaded.

So lets Say the app was packaged without that code &
Is there a particular way after GOJS is loaded, we can introduce JS to automate it using purely chrome console?
@walter

Without which code? The GoJS library must already be loaded.

So in the page that you want to test, is “go” not defined on the “window” object?

In the next release we could publish a reliable way to get the Diagram instance from an HTMLDivElement without the use of “go” being defined on “window”.

Thanks Walter

In the next release we could publish a reliable way to get the Diagram instance from an HTMLDivElement without the use of “go” being defined on “window”.

This is what I am looking for, Once without any additional code, when a dev deploys a gojs web page, A user should open chrome and navigate to that page, just use console and use javascript to do some automation / get the diagram and its nodes etc.

OK.

For the moment, in version 2.1.23, the minified property name on the HTMLDivElement is named “B” for getting the Diagram instance for that Div. So you can make progress for now and replace “.B” with whatever we end up documenting.

In version 2.1.24 you’ll be able to get the “goDiagram” property of the HTMLDivElement that you pass as the value of the Diagram.div property or as the first argument to the GraphObject.make function.

Furthermore, if the “go” namespace is not available for some reason (depending on how the app was packaged), you can get it as the “go” property on that HTMLDivElement. But the “go” property on the Div will only be defined by the go.js or go-module.js files (or their corresponding -debug files). If for some reason there is no namespace at all, for example in the future because you are building from sources and want to tree-shake-out stuff, there wouldn’t be any namespace object that would normally be named “go”. If you want something like that, you can implement it yourself.