cypress-example-kitchensink
Version:
This is an example app used to showcase Cypress.io testing. For a full reference of our documentation, go to https://docs.cypress.io
118 lines (105 loc) • 5.16 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Kitchen Sink | Cypress Example">
<meta name="author" content="Cypress.io">
<meta name="copyright" content="Cypress.io, Inc">
<title>Cypress.io: Kitchen Sink</title>
<link rel="icon" href="/assets/img/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/assets/css/vendor/bootstrap.min.css">
<link rel="stylesheet" href="/assets/css/vendor/fira.css">
<link rel="stylesheet" href="/assets/css/styles.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">cypress.io</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Commands <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/commands/querying">Querying</a></li>
<li><a href="/commands/traversal">Traversal</a></li>
<li><a href="/commands/actions">Actions</a></li>
<li><a href="/commands/window">Window</a></li>
<li><a href="/commands/viewport">Viewport</a></li>
<li class="active"><a href="/commands/location">Location</a></li>
<li><a href="/commands/navigation">Navigation</a></li>
<li><a href="/commands/assertions">Assertions</a></li>
<li><a href="/commands/misc">Misc</a></li>
<li><a href="/commands/connectors">Connectors</a></li>
<li><a href="/commands/aliasing">Aliasing</a></li>
<li><a href="/commands/waiting">Waiting</a></li>
<li><a href="/commands/network-requests">Network Requests</a></li>
<li><a href="/commands/files">Files</a></li>
<li><a href="/commands/storage">Storage</a></li>
<li><a href="/commands/cookies">Cookies</a></li>
<li><a href="/commands/spies-stubs-clocks">Spies, Stubs & Clocks</a></li>
</ul>
</li>
<li><a href="/utilities">Utilities</a></li>
<li><a href="/cypress-api">Cypress API</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li><a href="https://github.com/cypress-io/cypress-example-kitchensink">GitHub</a></li>
</ul>
</div>
</div>
</nav>
<div class="banner">
<div class="container">
<h1>Location</h1>
<p>Examples of get the url within your application in Cypress, for a full reference of commands, go to <a href="https://on.cypress.io/api" target="_blank">docs.cypress.io</a>
</p>
</div>
</div>
<div class="container content-container">
<div id="navigation">
<div class="row">
<div class="col-xs-12">
<h4 id="hash"><a href="https://on.cypress.io/hash">cy.hash()</a></h4>
<p>To get the current URL hash, use the <a href="https://on.cypress.io/hash"><code>cy.hash()</code></a> command.</p>
<pre><code class="javascript">cy.hash().should('be.empty')</code></pre>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-12">
<h4 id="location"><a href="https://on.cypress.io/location">cy.location()</a></h4>
<p>To get <code>window.location</code>, use the <a href="https://on.cypress.io/location"><code>cy.location()</code></a> command.</p>
<pre><code class="javascript">cy.location().should((location) => {
expect(location.hash).to.be.empty
expect(location.href).to.eq('http://localhost:8080/commands/location')
expect(location.host).to.eq('localhost:8080')
expect(location.hostname).to.eq('localhost')
expect(location.origin).to.eq('http://localhost:8080')
expect(location.pathname).to.eq('/commands/location')
expect(location.port).to.eq('8080')
expect(location.protocol).to.eq('http:')
expect(location.search).to.be.empty
})</code></pre>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-12">
<h4 id="url"><a href="https://on.cypress.io/url">cy.url()</a></h4>
<p>To get the current URL, use the <a href="https://on.cypress.io/url"><code>cy.url()</code></a> command.</p>
<pre><code class="javascript">cy.url().should('eq', 'http://localhost:8080/commands/location')</code></pre>
</div>
<div class="col-xs-12"><hr></div>
</div>
</div>
</div>
<script src="/assets/js/vendor/jquery-1.12.0.min.js"></script>
<script src="/assets/js/vendor/bootstrap.min.js"></script>
<script src="/assets/js/vendor/highlight.pack.js"></script>
<script src="/assets/js/scripts.js"></script>
</body>
</html>