<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Steve</title>
    <description>The latest articles on Forem by Steve (@stephencavender).</description>
    <link>https://forem.com/stephencavender</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F47612%2Fa1a13246-5eee-4de9-bb87-d70da1bf78ea.jpg</url>
      <title>Forem: Steve</title>
      <link>https://forem.com/stephencavender</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/stephencavender"/>
    <language>en</language>
    <item>
      <title>React-Native SVG Example</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Sat, 10 Apr 2021 04:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/react-native-svg-example-413j</link>
      <guid>https://forem.com/stephencavender/react-native-svg-example-413j</guid>
      <description>&lt;h2&gt;
  
  
  Series Intro
&lt;/h2&gt;

&lt;p&gt;Welcome to the first post of my React Native series! Each article in the series will dive into a different aspect of the framework. Let’s go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To begin we’ll need a React Native application to add SVGs to. I started a new one in my examples repo under &lt;code&gt;svg&lt;/code&gt; with the &lt;code&gt;npx react-native init PROJECTNAME&lt;/code&gt; command. An existing app will work as well but we’ll have to check version compatibility. Our next step is to fire up the app. I run &lt;code&gt;npm run start&lt;/code&gt; which just calls &lt;code&gt;react-native start&lt;/code&gt;. Now metro is running in this terminal and we need to open a new terminal. In the new terminal let’s fire up the app in either iOS or Android. I started with Android so I ran &lt;code&gt;npm run android&lt;/code&gt; which just runs &lt;code&gt;react-native run-android&lt;/code&gt;. Now we have an Android emulator running our app! Here’s a screenshot of where we’re at on Android:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Finit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Finit.png" title="Initial Screen" alt="Initial Screen" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Drawing SVGs
&lt;/h2&gt;

&lt;p&gt;React Native doesn’t support SVG out of the box. So we’ll have to install a package to handle SVGs for us. I chose &lt;a href="https://github.com/react-native-svg/react-native-svg" rel="noopener noreferrer"&gt;svg-react-native&lt;/a&gt;. Here’s where we need to pay attention to the versions we’re on. There are various steps to getting this package to work in the app depending on the versions it has. Be sure to read through the Readme and the &lt;a href="https://github.com/react-native-svg/react-native-svg#notice" rel="noopener noreferrer"&gt;table of versions&lt;/a&gt;. Since I’m on a brand new app I ran &lt;code&gt;npm i react-native-svg&lt;/code&gt; to install the latest. Now with the package installed we can import it and start drawing SVGs in our app! I added a separate component to contain my SVG: &lt;code&gt;/components/svg.js&lt;/code&gt;. Here’s my component code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import type {Node} from 'react';
import Svg, {Circle, Rect, Path} from 'react-native-svg';
import {View} from 'react-native';

const SvgComp = (): Node =&amp;gt; {
  return (
    &amp;lt;View&amp;gt;
      &amp;lt;Svg height="100" width="100"&amp;gt;
        &amp;lt;Rect x="0" y="0" width="100" height="100" fill="black" /&amp;gt;
        &amp;lt;Circle cx="50" cy="50" r="30" fill="yellow" /&amp;gt;
        &amp;lt;Circle cx="40" cy="40" r="4" fill="black" /&amp;gt;
        &amp;lt;Circle cx="60" cy="40" r="4" fill="black" /&amp;gt;
        &amp;lt;Path d="M 40 60 A 10 10 0 0 0 60 60" stroke="black" /&amp;gt;
      &amp;lt;/Svg&amp;gt;
    &amp;lt;/View&amp;gt;
  );
};

export default SvgComp;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here’s a screenshot of how it renders in the Android emulator:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fdrawing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fdrawing.png" title="SVG Drawing" alt="SVG Drawing" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I had to restart metro and re-run the android command to get SVGs working.&lt;/p&gt;




&lt;p&gt;Check out the &lt;a href="https://github.com/react-native-svg/react-native-svg#supported-elements" rel="noopener noreferrer"&gt;supported elements&lt;/a&gt; to see what else we can do with SVGs now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using an SVG Font
&lt;/h2&gt;

&lt;p&gt;Being able to draw our own SVGs is cool but let’s pull in an SVG font with a bunch of icons we can use. I chose a set of open source icons called &lt;a href="https://feathericons.com/" rel="noopener noreferrer"&gt;Feather&lt;/a&gt;. &lt;a href="https://yigithan.dev/" rel="noopener noreferrer"&gt;Yiğithan&lt;/a&gt; has already done the work for those of us that want to use Feather icon SVGs in our React Native apps with &lt;a href="https://github.com/yigithanyucedag/react-native-feather" rel="noopener noreferrer"&gt;react-native-feather&lt;/a&gt;. Install the package with &lt;code&gt;npm i react-native-feather&lt;/code&gt; and pop in any of the Feather icons. I created another separate component to try out Feather icons in my example app: &lt;code&gt;/components/feather.js&lt;/code&gt;. Here’s my component code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import type {Node} from 'react';
import {View} from 'react-native';
import {ArrowUpCircle} from 'react-native-feather';

const FeatherComp = (): Node =&amp;gt; {
  return (
    &amp;lt;View&amp;gt;
      &amp;lt;ArrowUpCircle stroke="red" fill="#fff" width={32} height={32} /&amp;gt;
    &amp;lt;/View&amp;gt;
  );
};

export default FeatherComp;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here’s a screenshot of how it renders in the Android emulator:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Ffeather-icon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Ffeather-icon.png" title="Feather Icon" alt="Feather Icon" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is great because now we have access to all of the Feather icons as React components. But what if we had an SVG file we wanted to use?&lt;/p&gt;

&lt;h2&gt;
  
  
  Using SVG Files
&lt;/h2&gt;

&lt;p&gt;Maybe we have some SVG files we want to include rather than including a font of them. For this case we’ll need another package. &lt;a href="https://github.com/kristerkari" rel="noopener noreferrer"&gt;Kristerkari&lt;/a&gt; has us covered with &lt;a href="https://github.com/kristerkari/react-native-svg-transformer" rel="noopener noreferrer"&gt;react-native-svg-transformer&lt;/a&gt;. Install the package with &lt;code&gt;npm i --save-dev react-native-svg-transformer&lt;/code&gt;. Next we’ll update our metro config to handle transforming SVGs. Here’s what my metro.config.js looks like now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {getDefaultConfig} = require('metro-config');

module.exports = (async () =&amp;gt; {
  const {
    resolver: {sourceExts, assetExts},
  } = await getDefaultConfig();
  return {
    transformer: {
      getTransformOptions: async () =&amp;gt; ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: true,
        },
      }),
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter(ext =&amp;gt; ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };
})();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I needed some SVG files so I grabbed these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A colorized one: &lt;a href="https://raw.githubusercontent.com/kristerkari/react-native-svg-example/master/logos/firefox.svg" rel="noopener noreferrer"&gt;firefox.svg&lt;/a&gt; from Kristerkari’s &lt;a href="https://github.com/kristerkari/react-native-svg-example" rel="noopener noreferrer"&gt;example repo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;And a customizable one: &lt;a href="https://feathericons.com/?query=coffee" rel="noopener noreferrer"&gt;coffee.svg&lt;/a&gt; from Feather&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And another new component for SVG files: &lt;code&gt;./components/svg-files.js&lt;/code&gt;. Here’s the component code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import type {Node} from 'react';
import {View} from 'react-native';
import Coffee from '../assets/icons/coffee.svg';
import Firefox from '../assets/icons/firefox.svg';

const SvgFilesComp = (): Node =&amp;gt; {
  return (
    &amp;lt;View&amp;gt;
      &amp;lt;Firefox /&amp;gt;
      &amp;lt;Coffee /&amp;gt;
    &amp;lt;/View&amp;gt;
  );
};

export default SvgFilesComp;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here’s a screenshot of how it renders in the Android emulator:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-init.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-init.png" title="SVG File Initial Screen" alt="SVG File Initial Screen" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I had to restart metro and re-run the android command to get SVGs working.&lt;/p&gt;




&lt;p&gt;Notice that our coffee SVG isn’t visible but taking space. That’s because its designed to be customizable. We need to pass in some arguments if we want it to render in color. Which arguments and whether it’s customizable at all depends on the SVG.&lt;/p&gt;

&lt;p&gt;For instance, both SVGs I chose have widths and heights set for them. If we don’t include those properties then their defaults are used. If we pass in a width to the firefox SVG check out what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Firefox width={50} /&amp;gt;
&amp;lt;Coffee /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-firefox-width.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-firefox-width.png" title="SVG File Firefox Width" alt="SVG File Firefox Width" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image is the correct size but the overall SVG is still taking up a lot more room than it needs. We have to pass in both sizes to fix this. While we’re at it, let’s give some color to our coffee icon by passing in a fill color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Firefox width={50} height={50} /&amp;gt;
&amp;lt;Coffee fill={'blue'} /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-firefox-size-coffee-fill.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-firefox-size-coffee-fill.png" title="SVG File Firefox Size Coffee Fill" alt="SVG File Firefox Size Coffee Fill" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now our firefox looks good but our coffee icon does not. This particular icon isn’t meant to have a fill. Rather, we should pass in a stroke to get the desired look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Firefox width={50} height={50} /&amp;gt;
&amp;lt;Coffee stroke={'#333'} /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-final.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.cavender.io%2Fassets%2Fimages%2Fposts%2Freact-native-svg%2Fsvg-file-final.png" title="SVG File Final" alt="SVG File Final" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now those are some good looking SVGs in a React Native app!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article we covered how to include SVGs inside a React Native application using three different methods:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drawing them&lt;/li&gt;
&lt;li&gt;Importing an SVG font&lt;/li&gt;
&lt;li&gt;Loading from .svg files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks for reading! Please share using any of the buttons below and stay tuned for more of my React Native series of posts. Don’t hesitate to reach out in the comments below or on any of the links in the author profile.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>svg</category>
      <category>vector</category>
    </item>
    <item>
      <title>MacOS OpenJDK Maintenance</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Sun, 21 Mar 2021 04:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/macos-openjdk-maintenance-1e5o</link>
      <guid>https://forem.com/stephencavender/macos-openjdk-maintenance-1e5o</guid>
      <description>&lt;h2&gt;
  
  
  What is OpenJDK?
&lt;/h2&gt;

&lt;p&gt;An open-source implementation of the Java platform SE. To read more check out &lt;a href="https://openjdk.java.net/" rel="noopener noreferrer"&gt;official site&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why have multiple versions?
&lt;/h2&gt;

&lt;p&gt;Why not? Not all apps are able to keep up with Java versions and those that do might need some time when a new version comes out. For example: I’m working with React-Native building mobile apps for both iOS and Android. To build the Android app it uses Gradle 6.5 which doesn’t support the latest version of Java (16) yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing
&lt;/h2&gt;

&lt;p&gt;I have OpenJDK installed through AdoptOpenJDK using brew. I like to keep all my apps and libs as up-to-date as possible so I run &lt;code&gt;brew upgrade&lt;/code&gt; a lot. One of those times it upgraded AdoptOpenJDK to 16. Lucky for me they also publish older versions on brew but there’s an extra step.&lt;/p&gt;

&lt;p&gt;My initial thought was to run &lt;code&gt;brew install adoptopenjdk@15&lt;/code&gt; but it didn’t work. The versioned casks are contained in their Tap which I found out by checking out their &lt;a href="https://formulae.brew.sh/cask/adoptopenjdk#default" rel="noopener noreferrer"&gt;brew page&lt;/a&gt; and subsequently their &lt;a href="https://github.com/AdoptOpenJDK/homebrew-openjdk" rel="noopener noreferrer"&gt;open-source tap code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So the fix was to get into the tap (&lt;code&gt;brew tap adoptopenjdk/openjdk&lt;/code&gt;) and run the command above again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switching between versions
&lt;/h2&gt;

&lt;p&gt;Now I have two versions of OpenJDK available to my system: 16 and 15. To switch between them I found a little function to pop into my .zshrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jdk() {
  export JAVA_VERSION=$1
  java -version
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to switch between JDK versions I run &lt;code&gt;jdk 15&lt;/code&gt; or any version I have installed.&lt;/p&gt;

</description>
      <category>java</category>
      <category>openjdk</category>
      <category>devsetup</category>
    </item>
    <item>
      <title>Dev Setup</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Mon, 16 Nov 2020 05:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/dev-setup-8cp</link>
      <guid>https://forem.com/stephencavender/dev-setup-8cp</guid>
      <description>&lt;p&gt;I try to keep my setup pretty minimal but the following is my list of must-haves. All are easily &lt;a href="https://startpage.com" rel="noopener noreferrer"&gt;searchable&lt;/a&gt; so I have not included links except to my settings hosted as GitHub Gists.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Physical 

&lt;ul&gt;
&lt;li&gt;MacBook Air (Light but powerful)&lt;/li&gt;
&lt;li&gt;Logitech MX Master 2S&lt;/li&gt;
&lt;li&gt;Bose QC 25&lt;/li&gt;
&lt;li&gt;Fidget Spinner&lt;/li&gt;
&lt;li&gt;Moleskine grid notebook&lt;/li&gt;
&lt;li&gt;Lamy Safari Fountain Pen&lt;/li&gt;
&lt;li&gt;Blackwing Pencil&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Digital 

&lt;ul&gt;
&lt;li&gt;Zsh (as well as Oh-my-zsh and zsh-completions) &lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/StephenCavender/91a3243a8b26d14f3ae6d0b747d2bba3" rel="noopener noreferrer"&gt;.zshrc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Brew&lt;/li&gt;
&lt;li&gt;NVM&lt;/li&gt;
&lt;li&gt;RVM&lt;/li&gt;
&lt;li&gt;VSCodium (No MS branding/telemetry) &lt;/li&gt;
&lt;li&gt;Extensions: 

&lt;ul&gt;
&lt;li&gt;Bookmarks&lt;/li&gt;
&lt;li&gt;Bracket Pair Colorizer 2&lt;/li&gt;
&lt;li&gt;ES7 React/Recux/GraphQL/React-native Snippets&lt;/li&gt;
&lt;li&gt;ESLint&lt;/li&gt;
&lt;li&gt;GitLens&lt;/li&gt;
&lt;li&gt;JavaScript (ES6) code snippets&lt;/li&gt;
&lt;li&gt;Live Server&lt;/li&gt;
&lt;li&gt;Material Icon Theme&lt;/li&gt;
&lt;li&gt;Night Owl&lt;/li&gt;
&lt;li&gt;REST Client&lt;/li&gt;
&lt;li&gt;SVG&lt;/li&gt;
&lt;li&gt;TODO Highlight&lt;/li&gt;
&lt;li&gt;YAML&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;a href="https://gist.github.com/StephenCavender/f821dd072238ba388d86da38903e8fc8" rel="noopener noreferrer"&gt;Settings&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;Firefox (main driver)&lt;/li&gt;

&lt;li&gt;Hyper&lt;/li&gt;

&lt;li&gt;LICEcap&lt;/li&gt;

&lt;li&gt;OBS&lt;/li&gt;

&lt;li&gt;Chromium (for testing apps)&lt;/li&gt;

&lt;li&gt;Chrome (for testing apps)&lt;/li&gt;

&lt;li&gt;Vanilla&lt;/li&gt;

&lt;li&gt;Time Out&lt;/li&gt;

&lt;li&gt;OpenJDK&lt;/li&gt;

&lt;li&gt;Nginx&lt;/li&gt;

&lt;li&gt;SVGO&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Dual-booting Linux Mint</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Fri, 08 Nov 2019 05:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/dual-booting-linux-mint-3cgk</link>
      <guid>https://forem.com/stephencavender/dual-booting-linux-mint-3cgk</guid>
      <description>&lt;h2&gt;
  
  
  Why Linux
&lt;/h2&gt;

&lt;p&gt;I’ve always heard that Linux is the way to go but I never tried it. I had Windows and it worked fine for me. I took some training at work that required Linux so I started using it inside a virtual machine. I got comfortable with it and decided it would be fun to try at home.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Mint
&lt;/h2&gt;

&lt;p&gt;Based on this &lt;a href="https://dev.to/pluralsight/which-distribution-of-linux-should-i-use-51g7"&gt;Dev.to&lt;/a&gt; article it sounded like where a Linux newbie like myself should start. I tried a couple versions inside VirtualBox before committing. I used &lt;a href="https://www.osboxes.org/" rel="noopener noreferrer"&gt;OSBoxes&lt;/a&gt; to quickly get them up and running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Dual-Boot
&lt;/h2&gt;

&lt;p&gt;I chose to dual-boot because I didn’t want to risk losing Windows if I messed up the Mint install. Also because the Mint install made it really easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I did it
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Disclaimer!
&lt;/h3&gt;

&lt;p&gt;I’ll recount the steps I took and the references I used but can’t guarantee any of it for anyone else.Also it’s a good idea to follow along with &lt;a href="https://www.linuxmint.com/documentation.php" rel="noopener noreferrer"&gt;Mint’s install docs&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Back Up Data
&lt;/h3&gt;

&lt;p&gt;I backed up my data because there’s always a chance it could get wiped from existence.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Download Linux Mint
&lt;/h3&gt;

&lt;p&gt;I grabbed the 64bit Cinnamon version from &lt;a href="https://linuxmint.com/download.php" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create a Bootable USB
&lt;/h3&gt;

&lt;p&gt;I used &lt;a href="https://www.balena.io/etcher/" rel="noopener noreferrer"&gt;Etcher&lt;/a&gt; to flash the image onto my USB drive but any flashing software should do the trick. &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.dev%2Fassets%2Fimages%2Flinux-dual-boot%2Fetcher.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.dev%2Fassets%2Fimages%2Flinux-dual-boot%2Fetcher.png" alt="Etcher" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Create Disk Space
&lt;/h3&gt;

&lt;p&gt;My first attempt didn’t take because I didn’t have any room. I ended up freeing up some space from my Windows partitions. &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.dev%2Fassets%2Fimages%2Flinux-dual-boot%2Fdisk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.dev%2Fassets%2Fimages%2Flinux-dual-boot%2Fdisk.png" alt="Disk Management" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Update Boot Configuration
&lt;/h3&gt;

&lt;p&gt;I had to disable secure boot and change the boot order in the BIOS.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Install Mint
&lt;/h3&gt;

&lt;p&gt;I followed the on-screen instructions at this point. Here are the important bits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dual booting with Windows&lt;/li&gt;
&lt;li&gt;Create partitions

&lt;ul&gt;
&lt;li&gt;Root (I used 20Gb)&lt;/li&gt;
&lt;li&gt;Swap (I used 8Gb)&lt;/li&gt;
&lt;li&gt;Home (I used the rest of my free space)A few more on-screen instructions and I was ready to go!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Use Mint
&lt;/h3&gt;

&lt;p&gt;Mint is installed and ready to go. I’m on a Razer Blade Stealth and everything works out of the box except for closing the lid. I’m sure there are other things that don’t quite work that I haven’t encountered yet. When I close the lid Mint is supposed to suspend but when I open the lid back up I have to hard shutdown before my laptop will wake up and respond. Other than that I’m very happy with Mint and hope that this article helps you!&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>JavaScript Selenium Mocha QuickStart Guide</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Wed, 20 Jul 2016 04:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/javascript-selenium-mocha-quickstart-guide-5a5k</link>
      <guid>https://forem.com/stephencavender/javascript-selenium-mocha-quickstart-guide-5a5k</guid>
      <description>&lt;h2&gt;
  
  
  Getting started with JavaScript, Selenium and Mocha!
&lt;/h2&gt;

&lt;p&gt;In this article we’ll be using Mocha and Selenium to write tests for web applications. This will be a starter project we can build on for various projects and in future articles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;p&gt;Here are the requirements before we get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;NodeJS&lt;/a&gt; (A JavaScript runtime)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://docs.seleniumhq.org/download/" rel="noopener noreferrer"&gt;Selenium JavaScript language bindings&lt;/a&gt; (But we’ll use NPM to grab these)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://mochajs.org/" rel="noopener noreferrer"&gt;MochaJS&lt;/a&gt; (Mocha is a JS test framework)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://chaijs.com/" rel="noopener noreferrer"&gt;ChaiJS&lt;/a&gt; (Chai is an assertion library)&lt;/li&gt;
&lt;li&gt;Any browsers installed that you want to test &lt;a href="http://docs.seleniumhq.org/about/platforms.jsp" rel="noopener noreferrer"&gt;Supported Platforms&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Selenium Prep
&lt;/h3&gt;

&lt;p&gt;If you haven’t read through my quick &lt;a href="https://www.cavender.io/selenium/selenium-overview-setup" rel="noopener noreferrer"&gt;Overview of Selenium&lt;/a&gt; you should do that now. Selenium will need a few things configured before it’ll do its magic!&lt;/p&gt;

&lt;h3&gt;
  
  
  NodeJs Tutorial
&lt;/h3&gt;

&lt;p&gt;If you’re unfamiliar with NodeJS I recommend this tutorial to get you started: &lt;a href="https://blog.risingstack.com/node-hero-tutorial-getting-started-with-node-js/" rel="noopener noreferrer"&gt;NodeHero&lt;/a&gt;. It’s packed with helpful information. It’s a good resource to keep open in a tab while working through this post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Project
&lt;/h3&gt;

&lt;p&gt;To kick things off we’ll need a new project. Using a command prompt or Explorer we need to create a new folder for our project. Once we have our folder we can use the command prompt to begin installing the packages we’ll need.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initializing Project
&lt;/h3&gt;

&lt;p&gt;NodeJS comes with its own package manager: NPM. It is also used to initialize a project. Run the following command and fill in each section: &lt;code&gt;npm init&lt;/code&gt;. This will create the &lt;strong&gt;package.json&lt;/strong&gt; file. This file tracks dependencies and project information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Packages
&lt;/h3&gt;

&lt;p&gt;NPM is also responsible for installing packages. The command for installing a package is &lt;code&gt;npm install &amp;lt;package&amp;gt;&lt;/code&gt;. We need to install Selenium, Mocha and Chai.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;npm install selenium-webdriver --save&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npm install mocha --save&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npm install chai --save&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These will install in the &lt;strong&gt;node_modules&lt;/strong&gt; folder and get tracked in our &lt;strong&gt;package.json&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;Here’s what our folder structure looks like: &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2Fstructure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2Fstructure.png" title="Folder structure" alt="Folder structure" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now write our first test and use our installed packages! Here’s what the package.json file should look like at this point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
"name": "selenium-js-mocha",
"version": "1.0.0",
"description": "A project to go along with blog posts explaining how to get started with functional testing using Selenium, JavaScript and Mocha. ",
"main": "test1.js",
"dependencies": {
"chai": "^3.5.0",
"mocha": "^2.5.3",
"selenium-webdriver": "^2.53.2"
},
"devDependencies": {},
"scripts": {
"test": "mocha test1.js"
},
"author": "Stephen Cavender",
"license": "ISC"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Write Test
&lt;/h3&gt;

&lt;p&gt;We’ll write our test against &lt;a href="http://the-internet.herokuapp.com/" rel="noopener noreferrer"&gt;The Internet&lt;/a&gt;&lt;sup id="fnref:theinternet"&gt;1&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;Let’s create a new JS file in our project folder: I’ll create test1.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Load dependecies
var assert = require('chai').assert,
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver');

// Our test
test.describe('Test', function () {
test.it('Title should be "The Internet"', function () {
// Set timeout to 10 seconds
this.timeout(10000);

// Get driver
// var driver = new webdriver.Builder().
// withCapabilities(webdriver.Capabilities.firefox()).
// build();
// var driver = new webdriver.Builder().
// withCapabilities(webdriver.Capabilities.edge()).
// build();
// var driver = new webdriver.Builder().
// withCapabilities(webdriver.Capabilities.ie()).
// build();
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();

// Go to URL
driver.get('http://the-internet.herokuapp.com');

// Find title and assert
driver.executeScript('return document.title').then(function(return_value) {
assert.equal(return_value, 'The Internet')
});

// Quit webdriver
driver.quit();
});
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Load dependencies&lt;/li&gt;
&lt;li&gt;Create test&lt;/li&gt;
&lt;li&gt;Set timeout (test runs too fast and fails without increasing the timeout)&lt;/li&gt;
&lt;li&gt;Get a web driver&lt;/li&gt;
&lt;li&gt;Set the URL property (tells the driver to go to that URL)&lt;/li&gt;
&lt;li&gt;Assert on the title of the driver&lt;/li&gt;
&lt;li&gt;Dispose of the driver&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Run Test
&lt;/h3&gt;

&lt;p&gt;Now that we have a functional test we can run it. Save the test file and let’s grab our command prompt. To run tests we call the mocha command and our test file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mocha test1.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run that in the command prompt and we should see our test run and the command prompt will tell us the result of the test. If the &lt;strong&gt;package.json&lt;/strong&gt; is set up with a test script we can also run our test by calling the npm test script.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is how the command prompt displays our test run: &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2FnpmTestCmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2FnpmTestCmd.png" title="Command prompt test run" alt="Command prompt test run" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is how bash displays our test run: &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2FnpmTestBash.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fjs-selenium-mocha%2FnpmTestBash.png" title="Bash test run" alt="Bash test run" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a basic, and brittle, example of how Selenium works. We’ll cover a much better testing approach in a later post to avoid such things! This is not an example of best practices by any means. This is to get you a working example of Selenium. Stay tuned for more posts on how to use Selenium, best practices for automating tests and video tutorials!&lt;/p&gt;

&lt;p&gt;Thanks for reading! Be sure to share this post if you found it helpful and don’t hesitate to chat with me about it!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Credit to &lt;a href="http://davehaeffner.com/" rel="noopener noreferrer"&gt;Dave Haeffner&lt;/a&gt;. ↩&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://cavender.dev/selenium/js-selenium-mocha-quickstart/" rel="noopener noreferrer"&gt;cavender.dev&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>mocha</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Selenium Overview &amp; Setup</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Sat, 25 Jun 2016 04:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/selenium-overview-amp-setup-k3j</link>
      <guid>https://forem.com/stephencavender/selenium-overview-amp-setup-k3j</guid>
      <description>&lt;h2&gt;
  
  
  Quick Selenium Overview
&lt;/h2&gt;

&lt;p&gt;In this article we’ll explore what Selenium is and how to prep our environment to use it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Selenium is an umbrella project for a range of tools and libraries that enable and support the automation of web browsers. - From &lt;a href="https://seleniumhq.github.io/docs/index.html" rel="noopener noreferrer"&gt;https://seleniumhq.github.io/docs/index.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Selenium enables us to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open browsers&lt;/li&gt;
&lt;li&gt;Navigate web pages&lt;/li&gt;
&lt;li&gt;Find web elements&lt;/li&gt;
&lt;li&gt;Manipulate web elements&lt;/li&gt;
&lt;li&gt;Run JavaScript&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Language Bindings
&lt;/h3&gt;

&lt;p&gt;First we’ll need to get the language bindings we want. The bindings will need to be downloaded and referenced in our project. Some IDE’s have package managers that will do this for us. We’ll talk more about how that’s done in separate articles. For now just know that we’ll need some language bindings to get Selenium to work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Webdrivers
&lt;/h3&gt;

&lt;p&gt;Selenium’s power comes from &lt;a href="http://docs.seleniumhq.org/docs/03_webdriver.jsp" rel="noopener noreferrer"&gt;webdrivers&lt;/a&gt;; called such because they “drive the web.” In the articles to come we’ll be using Chrome, Firefox, Edge and IE; we’ll need drivers for each.&lt;/p&gt;

&lt;h4&gt;
  
  
  Chrome
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://sites.google.com/a/chromium.org/chromedriver/" rel="noopener noreferrer"&gt;ChromeDriver&lt;/a&gt; is a separate executable loaded by Selenium when Chrome is the desired browser. Download the latest driver and place it in an easily-accessible location. I keep mine in &lt;code&gt;C:/webdrivers/&lt;/code&gt;. Download and install the latest &lt;a href="https://www.google.com/intl/en/chrome/browser/desktop/index.html" rel="noopener noreferrer"&gt;Chrome&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Firefox
&lt;/h4&gt;

&lt;p&gt;The &lt;a href="https://github.com/SeleniumHQ/selenium/wiki/FirefoxDriver" rel="noopener noreferrer"&gt;FirefoxDriver&lt;/a&gt; comes built-in with the Selenium language bindings. Download and install the latest &lt;a href="https://www.mozilla.org/en-US/firefox/all/" rel="noopener noreferrer"&gt;Firefox&lt;/a&gt;. Mozilla is working on a new driver for their browser called &lt;a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette" rel="noopener noreferrer"&gt;MarionetteDriver&lt;/a&gt;. However, it has not been released as of this writing. Feel free to download the latest driver and put it in the same location as the ChromeDriver.&lt;/p&gt;

&lt;h4&gt;
  
  
  Edge
&lt;/h4&gt;

&lt;p&gt;The &lt;a href="https://www.microsoft.com/en-us/download/details.aspx?id=48212" rel="noopener noreferrer"&gt;Microsoft WebDriver&lt;/a&gt; is a separate executable loaded up by Selenium when Edge is requested as a browser. Download the latest driver and keep it in the same location as the other driver(s). Make sure you have the latest updates for Edge.&lt;/p&gt;

&lt;h4&gt;
  
  
  IE
&lt;/h4&gt;

&lt;p&gt;The &lt;a href="http://docs.seleniumhq.org/download/" rel="noopener noreferrer"&gt;IEDriverServer&lt;/a&gt; is maintained and distributed by the Selenium group. Download the latest driver and put it in the same location as the other driver(s). Make sure you have the latest updates for IE.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding to PATH
&lt;/h3&gt;

&lt;p&gt;Now that we have all the drivers we’ll want to use we need to add an entry to our PATH environment variable. If you’ve never done anything with environment variables I would recommend reading this &lt;a href="http://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/" rel="noopener noreferrer"&gt;guide&lt;/a&gt;. Follow the instructions and add the folder containing your webdrivers.&lt;/p&gt;

&lt;p&gt;Now Selenium will be ready to go! Check out one of my other articles for the environment you want to use with Selenium:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.cavender.io/selenium/dotnet-selenium-mstest-quickstart" rel="noopener noreferrer"&gt;C#, Selenium &amp;amp; MSTest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cavender.io/selenium/js-selenium-mocha-quickstart" rel="noopener noreferrer"&gt;JavaScript, Selenium &amp;amp; Mocha&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading! Be sure to share this post if you found it helpful and don’t hesitate to chat with me about it!&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://cavender.dev/selenium/selenium-overview-setup/" rel="noopener noreferrer"&gt;cavender.dev&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>C# Selenium MSTest QuickStart Guide</title>
      <dc:creator>Steve</dc:creator>
      <pubDate>Sat, 18 Jun 2016 04:00:00 +0000</pubDate>
      <link>https://forem.com/stephencavender/c-selenium-mstest-quickstart-guide-31p9</link>
      <guid>https://forem.com/stephencavender/c-selenium-mstest-quickstart-guide-31p9</guid>
      <description>&lt;h2&gt;
  
  
  Getting started with C#, Selenium and MSTest!
&lt;/h2&gt;

&lt;p&gt;In this article we’ll be using MSTest and Selenium to write tests for web applications. This will be a starter project we can build on for various projects and in future articles.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;p&gt;Here are the requirements before we get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt; (A Microsoft Integrated Development Environment or IDE)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://docs.nuget.org/consume/installing-nuget" rel="noopener noreferrer"&gt;Nuget&lt;/a&gt; (A package manager for Visual Studio)&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://docs.seleniumhq.org/download/" rel="noopener noreferrer"&gt;Selenium C# language bindings&lt;/a&gt; (But we’ll use NuGet to grab these)&lt;/li&gt;
&lt;li&gt;Any browsers installed that you want to test &lt;a href="http://docs.seleniumhq.org/about/platforms.jsp" rel="noopener noreferrer"&gt;Supported Platforms&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Selenium Prep
&lt;/h3&gt;

&lt;p&gt;If you haven’t read through my quick &lt;a href="https://www.cavender.io/selenium/selenium-overview-setup" rel="noopener noreferrer"&gt;Overview of Selenium&lt;/a&gt; you should do that now. Selenium will need a few things configured before it’ll do its magic!&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Project
&lt;/h3&gt;

&lt;p&gt;To kick things off we’ll need a new project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File &amp;gt; New &amp;gt; Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fnew-project.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fnew-project.png" title="Create a new project" alt="Create a new project" width="800" height="400"&gt;&lt;/a&gt;Select the Unit Test Project template ( &lt;strong&gt;Templates &amp;gt; Visual C# &amp;gt; Test&lt;/strong&gt; ), give it a name and configure some options. Press Ok to create the project. Visual Studio will create the project and open up your first UnitTest class. &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fnew-project-first-view.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fnew-project-first-view.png" title="New project's first view" alt="New project's first view" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Import/Install Selenium
&lt;/h3&gt;

&lt;p&gt;Now we’ll need to grab the Selenium DLLs and give our project access to them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools &amp;gt; NuGet Package Manager &amp;gt; Manage NuGet Packages for Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fopen-nuget.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cavender.io%2Fassets%2Fimages%2Fdotnet-selenium-mstest%2Fopen-nuget.png" title="Open NuGet" alt="Open NuGet" width="800" height="400"&gt;&lt;/a&gt;Select Browse, search for ‘Selenium’ and install both Selenium.WebDriver and Selenium.Support for your new project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Write Test
&lt;/h3&gt;

&lt;p&gt;Now the fun begins; we can write the first Selenium test! We’ll write our test against &lt;a href="http://the-internet.herokuapp.com/" rel="noopener noreferrer"&gt;The Internet&lt;/a&gt;&lt;sup id="fnref:theinternet"&gt;1&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;Here’s some code to put inside the &lt;strong&gt;TestMethod1()&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//var driver = new OpenQA.Selenium.Firefox.FirefoxDriver
//var driver = new OpenQA.Selenium.Edge.EdgeDriver
//var driver = new OpenQA.Selenium.IE.InternetExplorerDriver
var driver = new OpenQA.Selenium.Chrome.ChromeDriver
{
Url = "http://the-internet.herokuapp.com/"
};
Assert.IsTrue(driver.Title == "The Internet");
driver.Dispose();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Get a web driver&lt;/li&gt;
&lt;li&gt;Set the URL property (tells the driver to go to that URL)&lt;/li&gt;
&lt;li&gt;Assert on the title of the driver&lt;/li&gt;
&lt;li&gt;Dispose of the driver&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Run Test
&lt;/h3&gt;

&lt;p&gt;Now that we have a functional test we can run it. First, if the Test Explorer isn’t displayed we need to add it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test &amp;gt; Windows &amp;gt; Test Explorer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our test isn’t showing up yet. We need to build the solution for it to recognize that we’ve written a test it can run. Right click on the solution in the Solution Explorer and Build or Rebuild the solution. If the build is successful we should see our test show up in the Test Explorer. Now we can right click on our test and tell it to run. If all went according to plan we should see a Chrome window pop up, navigate to Google’s home page and then close.&lt;/p&gt;

&lt;p&gt;This is a basic, and brittle, example of how Selenium works. If our assertion returns false the test will report a failure but the browser window will still be alive. This test is brittle in that it can’t run any code after the Assert if the Assert returns false. We’ll cover a much better testing approach in a later post to avoid such things! This is not an example of best practices by any means. This is to get you a working example of Selenium. Stay tuned for more posts on how to use Selenium, best practices for automating tests and video tutorials!&lt;/p&gt;

&lt;p&gt;Thanks for reading! Be sure to share this post if you found it helpful and don’t hesitate to chat with me about it!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Credit to &lt;a href="http://davehaeffner.com/" rel="noopener noreferrer"&gt;Dave Haeffner&lt;/a&gt;. ↩&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Originally published at &lt;a href="https://cavender.dev/selenium/dotnet-selenium-mstest-quickstart/" rel="noopener noreferrer"&gt;cavender.dev&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>mstest</category>
      <category>dotnet</category>
    </item>
  </channel>
</rss>
