Java Code Examples for org.testng.mustache.Value

Following code examples demonstrate how to use org.testng.mustache.Valuefrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.testng.mustache.Valueand various code implementation of this class.

	public void openBrowser() throws Exception{
		Properties prop = new Properties();
		try
		{
		InputStream input = new FileInputStream(new File("resources/Value.properties"));
		prop.load(input);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
        url=prop.getProperty("url");
		searchName=prop.getProperty("searchName");	
		Arguments obj=new Arguments();
		Reporter.log("Opening Chrome Browser");
		WebDriver driver= obj.setPath();
		Reporter.log("Opening Url");
	    driver.get(url);
	    WebElement element1 =obj.finder("lst-ib");
	    Reporter.log("Selecting search bar");
	    element1.sendKeys(searchName);
	    Reporter.log("Making Search");
	    WebElement element2=obj.finder("_fZl");
	    element2.click();   
	} 


    public void Set(String value){
        Find();
        myControl.sendKeys(value);
    } 

	private By getBy(String type,String value){
		By by = null ;
		switch (type.trim()) {
		case "id":
			by = By.id(value);
			break;
		case "name":
			by = By.name(value);
			break;
		case "className":
			by = By.className(value);
			break;
		case "tagName":
			by = By.tagName(value);
			break;
		case "linkText":
			by = By.linkText(value);
			break;
		case "partialLinkText":
			by = By.partialLinkText(value);
			break;
		case "xpath":
			by = By.xpath(value);
			break;
		case "cssSelector":
			by = By.cssSelector(value);
			break;
		default:
			System.out.println("Ԫ�ض�λ���� By" + type + "������");
			break;
		}
		return by;
	} 

	private WebElement getElement(String page ,String object , boolean wait){
		WebElement element = null ;
		existFlag = false ;
		
		if(xp.isExist("����/" + page + "/" + object)){
			String type = xp.getElementText("����/" + page + "/" + object + "/type");
			String value = xp.getElementText("����/" + page + "/" + object + "/value").trim();
			final By by = getBy(type, value);
			if(wait){
				try {
					element = new WebDriverWait(driver, timeOutInSeconds).until(new ExpectedCondition<WebElement>() {
						@Override
						public WebElement apply(WebDriver d) {
							existFlag = true ;
							return driver.findElement(by);
						}
					});
					if(! waitElementToBeDisplayed(element, page, object)){
						System.out.println(page + "-" + object + "δ��ҳ����ʾ��");
					}
				} catch (Exception e) {
					System.out.println("δ���ҵ�ҳ��Ԫ��" + page + "-" +object);
				}
			}else{
				return driver.findElement(by);
			}
		}else{
			System.out.println(page + "-" + object + "δ�ڶ�����ļ��д���");
		}
		return element ;
	} 

	public void selectByValue(String pageKey ,String objKey ,String value){
		Select select = select(pageKey, objKey);
		select.selectByValue(value);
	} 

	private List<WebElement> getElements(String page ,String object , boolean wait){
		List<WebElement > elements = new ArrayList<WebElement>() ;
		
		if(xp.isExist("����/" + page + "/" + object)){
			String type = xp.getElementText("����/" + page + "/" + object + "/type");
			String value = xp.getElementText("����/" + page + "/" + object + "/value").trim();
			By by = getBy(type, value);
			elements = driver.findElements(by);
			if(elements.size()==0){
				System.out.println("δ�ҵ�ҳ��Ԫ�أ�" + page + "-" + object);
			}else{
				for(WebElement e:elements){
					if(e.equals("")||e==null){
						System.out.println("���ض���������д��ڿ�ֵ��" + page + "-" + object);
					}
				}
			}
		}else{
			System.out.println(page + "-" + object + "δ�ڶ�����ļ��д���");
		}
		return elements ;
	} 

	public void verifyElementIsEnabled(Status statusof,WebElement enterelementlocator) {
	
		if (statusof==Status.enable) {
			boolean value=enterelementlocator.isEnabled();
			assertTrue(value);
		}
		else if (statusof==Status.disble) {
			boolean value=enterelementlocator.isEnabled();
			assertFalse(value);
		}
	
	} 

    }

    public String Valueconversion(String LtpValue)
    {
        LtpValue = LtpValue.substring(2).replace(",", "");
        System.out.println(LtpValue);
        return LtpValue;
    } 

			public void llenadocarrito(String q1, String q2, String q3) { 
				
				
				txtCore = driver.findElement(By.name("q1"));

				txtCore.sendKeys(q1);
				
				txtRuby = driver.findElement(By.name("q2"));

				txtRuby.sendKeys(q2);
				
				txtPython = driver.findElement(By.name("q3"));

				txtPython.sendKeys(q3);
				
				Value = driver.findElement(By.Value("Add"));
				
				Value.click();

			} 

	public  void selectddvalues() throws InterruptedException {
		System.setProperty("webdriver.gecko.driver", "C:\\Users\\shubham\\Desktop\\geckodriver.exe");

		WebDriver dr = new FirefoxDriver();
		dr.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);
		dr.findElement(By.xpath("html/body/div[1]/div[2]/div[2]/div[1]/div/form/div/div[7]/a")).click();
		dr.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);

		Select month_dd=new Select(month_dropdown);


		month_dd.selectByValue("15");
	

		Select month_mm=new Select(month_dropdown2);
		month_mm.selectByVisibleText("FEB");
		Thread.sleep(3000);
		Select month_yy=new Select(month_dropdown4);
		month_yy.selectByValue("1994");


		for(int i=0;i<radio.size();i++)
		{
			WebElement radio_local=radio.get(i);
			String value=radio_local.getAttribute("value");
			System.out.println("value from radio buttons");
		
			if(value.equalsIgnoreCase("male"))
			{
				radio_local.click();
			}
		}
		
	} 

Advertisement
Related Classes
Advertisement