C#: Selenium Selectors

Drupal8 Logout Link at footer ( XPath vs LinkText )

  • Had MUCH difficulty hooking into the logout link using XPATH for
  • JS window.scrollTo
  • By.LinkText(“Log out”) seems to be more accessible
  • using By.LinkText allowed Selenium to natively 'scroll to' on the 'Click()' method

Selenium basic selectors


el = driver.FindElement(By.XPath("//a[@href='/uc/user/logout']"));


el = driver.FindElement(By.Id("username"));


el = driver.FindElement(By.LinkText("Log out"));

JS scrollIntoView

  • when element found by XPath(//a), this didn't work
el = driver.FindElement(By.LinkText("Log out"));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", el);



C#: Classes - Base & Sub

  • To create a sub class,
  • add ' : <classname>' to the class statement
  • add :' base()' to the constructor

Base Class WITHOUT Arguments

  • If Base Class accepts NO arguments, the subclass doesn't need to include the 'base class constructor'
    class BaseClass
        public BaseClass()
  • Constructor doesn't need an explicit reference to the base class
    class Base_SubClass : BaseClass
       public Base_SubClass()
  • This is also valid & probably preferred

    class Base_SubClass : BaseClass
       public Base_SubClass() : BaseClass() {}

Base Class WITH Arguments

  • If Base Class constructor TAKES arguments, the subclass constructor must include them explicitly


C#: VIsualStudio 2017 IISE Setup Considerations

Simple Answer

It looks like you are missing a binding information entry in applicationhost.config file.

  1. Open your applicationhost.config file. Possible locations are:

    • %userprofile%\Documents\IISExpress\config\applicationhost.config
    • $(solutionDir)\.vs\config\applicationhost.config (VS2015)
    • Failing that, inspect the output from iisexpress.exe to be sure.
  2. Locate your WebSite entry and add following binding with your machine name.

Win7: netsh Commands For Network Interface Settings via CLI

Dos Shell Script

@echo off
echo This script must be ran as ADMIN
set ipAddr=
set subMask=
set gwAddr=
set dns=dhcp
set dnsAddr=

echo %COMPUTERNAME% - %ipAddr% - %subMask% - %gwAddr% - %dnsAddr%
echo Setting inferace values now... CTRL-C to cancel
netsh interface ip set address name="Local Area Connection" static %ipAddr% %subMask% %gwAddr%
netsh interface ip set dns "Local Area Connection" source=dhcp

netsh Commands

Show if config

netsh interface ip show config

Set if to static

netsh interface ip set address name="Local Area Connection" static

Set DNS for DHCP

netsh interface ip set dns "Local Area Connection" source=dhcp

Set DNS to static value


SpecFlow: 00 - Quick Setup & Test

  • Getting started with SpecFlow begins with setting up the environment & getting proof of concept working
  • Install VS2017, SpecFlow IDE Extension
  • Add Project
  • Install NuGet Packages for SpecFlow, NUnit & NUnit3 Test Adapter
  • Add SpecFlow Feature File
  • Generate Test Definitions
  • Replace method statement stubs with Console.Writeln() statements
  • Build project & Run Test
  • Ensure Test Passed & produced output

VisualStudio Setup

Install Visual Studio 2017 & Dependencies

SpecFlow IDE Plugin

Tools > Extensions and Updates

Search for SpecFlow & Install

SpecFlow NuGet

References > Manage NuGet Packages

Search for SpecFlow & Install

NUnit NuGet

References > Manage NuGet Packages

Search for NUnit & Install


Java POM: 09-Selenium Tricks

Common Selector Strategies

Page Title

return driver.getTitle();



element = driver.findElement(By.id("edit-field-tags-target-id"));
return element;



element = driver.findElement(By.xpath("//iframe[@title='Rich Text Editor, Body field']"));


Explicit Waits

int timeoutSec = 15;
WebDriverWait wait = new WebDriverWait(driver, timeoutSec);
wait.until((driver) -> driver.findElements(By.xpath("//a[@href='/uc/user/login']")).size()>0);
wait.until((driver) -> driver.findElement(By.xpath("//a[@href='/uc/user/login']")).isDisplayed());



CucumberJVM: 00 - Gherkin Language

Basic Gherkin Feature Model

Feature: User can create an article

Scenario: user logs in
Given user is on HomePage
When user navigates to LoginPage
And user enters UserName and Password
Then message displayed Login Successful

Scenario: user creates a new article
Given user is logged in and on HomePage
When user clicks CreateArticleLink
And user enters ArticleTitle
And user enters ArticleBody
And user neters ArticleTags
And user clicks NewArticleSubmitButton
Then message is displayed Article Created Successfully
And NewArticlePage title is MyNewArticle

Feature Keyword

  • Defines the functionality the test targets
  • Multiple scenarios can be created to cover this functionality
Feature: User can create an article
Feature: User can create an article

This feature will ensure a user can login and the product handles invalid credentials correctly
Feature: User can create an
Subscribe to