Answers for "selenium"

7

what is selenium

- Selenium is a set of libraries that help us automate and interact 
  with the browsers.
  
  Why Selenium?
  - OPEN SOURCE -> FREE
    - It supports different types of browsers
    - It supports multiple different programming languages
    - Huge community behind it so many answers to any problems/questions
    - Could run on different OS systems such as: Mac, Windows, Linux etc.
Posted by: Guest on December-04-2020
0

selenium java

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
import java.time.Duration;

public class HelloSelenium {

    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
        try {
            driver.get("https://google.com/ncr");
            driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
            WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div")));
            System.out.println(firstResult.getAttribute("textContent"));
        } finally {
            driver.quit();
        }
    }
}
Posted by: Guest on January-01-2021
2

selenium python example

import unittest
from selenium import webdriver
import time


class TestThree(unittest.TestCase):

    def setUp(self):
        self.startTime = time.time()

    def test_url_fire(self):
        time.sleep(2)
        self.driver = webdriver.Firefox()
        self.driver.get("https://app.simplegoods.co/i/IQCZADOY") # url associated with button click
        button = self.driver.find_element_by_id("payment-submit").get_attribute("value")
        self.assertEquals(u'Pay - $60.00', button)

    def test_url_phantom(self):
        time.sleep(1)
        self.driver = webdriver.PhantomJS()
        self.driver.get("https://app.simplegoods.co/i/IQCZADOY") # url associated with button click
        button = self.driver.find_element_by_id("payment-submit").get_attribute("value")
        self.assertEquals(u'Pay - $60.00', button)

    def tearDown(self):
        t = time.time() - self.startTime
        print("%s: %.3f" % (self.id(), t))
        self.driver.quit()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestThree)
    unittest.TextTestRunner(verbosity=0).run(suite)
Posted by: Guest on May-27-2020
0

why selenium

- Selenium is a set of libraries that help us automate and interact 
  with the browsers.
  
  Why Selenium?
    - OPEN SOURCE -> FREE
    - It supports different types of browsers
    - It supports multiple different programming languages
    - Huge community behind it so
      many answers to any problems/questions
    - It can run on different Operaing systems
      such as: Mac, Windows, Linux etc.
Posted by: Guest on December-04-2020
0

what version of selenium using

3.141.59
Posted by: Guest on January-06-2021
0

selenium

@Test
public void dragSlider() throws InterruptedException {	
		
	//1. Launch browser and maximize
	System.setProperty("webdriver.chrome.driver", "/home/joy/Documents/Eclipse/Workspace/GETEC_Handson/mavenproject/lib/chromedriver");	
	WebDriver driver = new ChromeDriver();
	driver.manage().window().maximize();
	
	//2. Navigate to destination Url
	String destinationUrl = "https://jqueryui.com/slider/#rangemin";
	driver.navigate().to(destinationUrl);
	
	//3. Switch to Iframe
	WebElement iframeXpath = driver.findElement(By.xpath("//div[@id='content']/iframe"));
	driver.switchTo().frame(iframeXpath);
	
	//4. Find slider tip
	WebElement sliderXpath = driver.findElement(By.xpath("//div[@id='slider-range-min']/span"));
	
	//5. Drag it
	Actions act = new Actions(driver);
	act.dragAndDropBy(sliderXpath, 378, 54).perform();
	
	//6. Wait for 5 seconds
	Thread.sleep(5000);
	
	//7. close
	driver.close();
		
  }
Posted by: Guest on September-08-2021

Browse Popular Code Answers by Language