C#: 25-Class get/set

  • using getter/setters allows for logic to be used in the process
  • for gets, null checking can be performed for Singleton Design Patterns or different things can be returned based on state/value.
  • for sets, null checking & data validation can be performed on the incoming values

Object Instantiation with Property Sets

See Also: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers

When an object is instantiated, the values can be set in the same statement

Car myCar = new Car{Type="Honda",Price=15000};

 

Tags

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

XPath

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

Id

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

LinkText

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);

ILoc

Tags

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

Tags

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=192.168.0.81
set subMask=255.255.255.0
set gwAddr=192.168.0.1
set dns=dhcp
set dnsAddr=208.180.42.68

echo %COMPUTERNAME% - %ipAddr% - %subMask% - %gwAddr% - %dnsAddr%
echo Setting inferace values now... CTRL-C to cancel
pause
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 192.168.0.81 255.255.255.0 192.168.0.1

Set DNS for DHCP

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

Set DNS to static value

Tags

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

Tags

Java POM: 09-Selenium Tricks

Common Selector Strategies

Page Title

return driver.getTitle();

 

findElement(By.id

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

 

findElement(By.xpath

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());

 

Tags
Subscribe to