Code Monkey home page Code Monkey logo

glance-dom's Introduction

Glance DOM

Glance is a simple way to reference elements in the DOM. It’s intention and hope is to keep you from looking at the DOM in order to gain a handle to an element. However, if you do inspect the DOM (for example to grab a class or an id off of an element in case that's your only option) then referencing elements by classes and id’s are supported too.

To best understand how it works, experimenting with it goes a long way. You can learn how to read Glance by playing a game at Come Take A Glance or by tinkering around with our CodePens. Learn even more at Quasimatic.org

Documentation

For details on all good things that are Glance, come read the docs here.

Documenting everything is currently being worked on so if there are differences between what you see here and what you see in the GitBook, please bare with us as we're working hard to pull them together. Nothing is inconsistant between the two, but you might find some here and some there for just a while.

Browser

If you want to use Glance DOM in your Browser simply include it in a <script> tag on your page as shown below and then use it as shown below in example-script.js

<html>
  <body>
    <button type="submit">Buy It!</button>
    
    <script src="http://quasimatic.org/glance-dom/dist/glance-dom.js" type="text/javascript"></script>
    <script src="example-script.js" type="text/javascript"></script>
  </body>
</html>
NOTE: In the above example Glance is being served over http. It is also available at https://quasimatic.org/glance-dom/dist/glance-dom.js

And then in your example-script.js file you can find the element that contains "Buy It!" by executing the following:

var element = glanceDOM("Buy It!");

Once executed, element will contain the button element that contains the text "Buy It!". You never had to drop down to using any kind of CSS selector, or God forbid XPATH :)

Node

npm install glance-dom

Example

script.js

var glanceDOM = require("glance-dom").default;
var element = glanceDOM("click me");

glance-dom's People

Contributors

beyondevil avatar corywheeler avatar dangilkerson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

glance-dom's Issues

Use setuptools for packaging

Update the packaging (setup.py) to use setuptools instead. This will make tracking versions easier and we'll have more flexibility in the package.

Node version does not work as expected

Hi guys, trying to execute code sample from README for node, and see following error

Users/alexanderpopov/github/sample/node_modules/glance-dom/javascript/lib/glance-dom.js:44
		if (!_this.execute) throw Error('Please provide an execute function using setExecute');
		                    ^

Error: Please provide an execute function using setExecute
    at CreateGlanceDOM.ensureGlanceDOMLoadedAndExecute (/Users/alexanderpopov/reps/github/protractor-extensions/node_modules/glance-dom/javascript/lib/glance-dom.js:44:29)
    at CreateGlanceDOM.selector (/Users/alexanderpopov/reps/github/protractor-extensions/node_modules/glance-dom/javascript/lib/glance-dom.js:78:16)
    at Object.<anonymous> (/Users/alexanderpopov/reps/github/protractor-extensions/test.js:2:15)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:187:16)

Am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.