In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Package com.appium.test
/ * *
* @ author YuFeifei
* @ version 11:41:21 on November 15, 2017
* Class description
* split key and value based on the read configuration file
* value is then divided into location type (locatorType) and element (locatorValue) through split
, /
Import org.openqa.selenium.By
Public class GetByLocatorTest {
Public static By getLocator (String key) {
ProUtilTest properties = new ProUtilTest (". / configs/test1.properties")
/ * * attribute locator is the value*/ obtained through key
String locator = properties.getProp (key)
/ * * data separated by split in value obtained by attribute locatorType > previous data = = id, name, etc. * /
String locatorType = locator.split (">") [0]
/ * * data separated by split in value obtained by attribute locatorType = = element * /
String locatorValue = locator.split (">") [1]
System.out.println ("Type of location acquired:" + locatorType + "\ t gets the element:" + locatorValue)
/ * * return the positioning method according to the positioning type * /
If (locatorType.toLowerCase (). Equals ("id")) / / toLowerCase () converts uppercase characters to lowercase
Return By.id (locatorValue)
Else if (locatorType.toLowerCase () .equals ("name")
Return By.name (locatorValue)
Else if (locatorType.toLowerCase () .equals ("classname")
Return By.className (locatorValue)
Else if (locatorType.toLowerCase () .equals ("tagname")
Return By.tagName (locatorValue)
Else if (locatorType.toLowerCase () .equals ("linktext")
Return By.linkText (locatorValue)
Else if (locatorType.toLowerCase () .equals ("cssselector")
Return By.cssSelector (locatorValue)
Else if (locatorType.toLowerCase () .equals ("xpath")
Return By.xpath (locatorValue)
Else
Try {
Throw new Exception ("the locatorType entered is not defined in the default program:" + locatorType + "Please check the class GetByLocatorTest")
} catch (Exception e) {
E.printStackTrace ()
}
Return null
}
/ * * Test * /
Public static void main (String agrs []) {
GetByLocatorTest test2 = new GetByLocatorTest ()
System.out.println (test2.getLocator ("LG_NAME_PHONE"))
}
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.