Skip to content

Instantly share code, notes, and snippets.

@SarahElson
SarahElson / Selenium C# test.cs
Last active September 15, 2022 10:55
Selenium C# test
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumTutorial
{
public class SeleniumTests
{
private IWebDriver driver;
@SarahElson
SarahElson / pom.xml
Created June 20, 2022 12:05
How to select multiple checkboxes in Selenium WebDriver using Java?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MultipleCheckboxes</groupId>
<artifactId>MultipleCheckboxes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@SarahElson
SarahElson / BaseClass.java
Created June 20, 2022 12:07
How to select multiple checkboxes in Selenium WebDriver using Java?
package test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.Selenium.remote.DesiredCapabilities;
import org.openqa.Selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@SarahElson
SarahElson / TestCheckboxes.java
Created June 20, 2022 12:17
How to select multiple checkboxes in Selenium WebDriver using Java?
package test;
import java.util.List;
import org.openqa.Selenium.By;
import org.openqa.Selenium.WebElement;
import org.testng.annotations.Test;
public class TestCheckboxes extends BaseClass{
@SarahElson
SarahElson / Desired Capability Generator
Last active June 22, 2022 07:04
Speed Up Accessibility Testing With LambdaTest And Evinced
//imports...
public class LambdaTest {
private String testName;
public static final String demoPage = "https://demo.evinced.com/";
private RemoteWebDriver webDriver;
private String Status = "failed";
@BeforeMethod
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
@SarahElson
SarahElson / @BeforeMethod
Last active June 21, 2022 17:42
Speed Up Accessibility Testing With LambdaTest And Evinced
private EvincedWebDriver driver;
@BeforeMethod
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
String username = System.getenv("LT_USERNAME");
String authkey = System.getenv("LT_ACCESS_KEY");
String hub = "@hub.lambdatest.com/wd/hub";
DesiredCapabilities caps = new DesiredCapabilities();
@SarahElson
SarahElson / @AfterMethod
Last active June 22, 2022 07:03
Speed Up Accessibility Testing With LambdaTest And Evinced
@AfterMethod
public void tearDown() {
// Stop the Evinced engine and generate the report object
Report report = driver.evStop();
// Export the report - JSON
EvincedReporter.writeEvResultsToFile("Evinced-LambdaTest-A11y-JSONReport", report, EvincedReporter.FileFormat.JSON);
// Export the report - HTML
EvincedReporter.writeEvResultsToFile("Evinced-LambdaTest-A11y-HTMLReport", report, EvincedReporter.FileFormat.HTML);
driver.quit();
}
@SarahElson
SarahElson / Pipfile
Created June 29, 2022 17:20
How To Get Current URL In Selenium Python
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[packages]
pytest = "*"
selenium = "*"
[requires]
python_version = "*"
@SarahElson
SarahElson / ecommerce_playground.py
Created June 29, 2022 17:31
How To Get Current URL In Selenium Python
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
class EcommercePlaygroundPage:
#url
url = 'https://ecommerce-playground.lambdatest.io/'
#locators
search_form = (By.NAME, "search")
search_button = (By.CSS_SELECTOR, ".type-text")
# Initializer
def __init__(self, browser):
@SarahElson
SarahElson / test_ecommerce_playground.py
Created June 29, 2022 17:33
How To Get Current URL In Selenium Python
import pytest
from pages.ecommerce_playground import EcommercePlaygroundPage
keyword = "iPhone"
def test_ecommerce_playground(browser):
ecommerce_page = EcommercePlaygroundPage(browser)
ecommerce_page.load()
ecommerce_page.search(keyword)
get_url = browser.current_url
title = browser.title
print("The current url is: "+str(get_url))