How to use CaseInsensitiveConverter method of com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter.CaseInsensitiveConverter

Source:CaseInsensitiveWebTest.java Github

copy

Full Screen

...14 * limitations under the License.15 *******************************************************************************/16package com.qaprosoft.carina.core.foundation.webdriver.locator;17import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.LocatorConverter;18import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;19import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.ParamsToConvert;20import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.Platform;21import org.openqa.selenium.By;22import org.testng.Assert;23import org.testng.annotations.Test;24public class CaseInsensitiveWebTest {25 @Test26 public void testWebTextLocatorWithSingleQuote() {27 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);28 String xpath = "//div[text() = 'Text text']";29 By expectedRes = By.xpath("//div[translate(text(), 'TEXT TEXT', 'text text')=translate('Text text', 'TEXT TEXT', 'text text')]");30 By result = converter.convert(By.xpath(xpath));31 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");32 }33 @Test34 public void testWebTextLocatorWithDoubleQuotes() {35 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);36 String xpath = "//div[text() = \"Text text\"]";37 By expectedRes = By.xpath("//div[translate(text(), \"TEXT TEXT\", \"text text\")=translate(\"Text text\", \"TEXT TEXT\", \"text text\")]");38 By result = converter.convert(By.xpath(xpath));39 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");40 }41 @Test42 public void testWebTextLocatorWithSingleQuoteAndContains() {43 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);44 String xpath = "//div[contains(text(), 'Text text')]";45 By expectedRes = By.xpath("//div[contains(translate(text(), 'TEXT TEXT', 'text text'),translate('Text text', 'TEXT TEXT', 'text text'))]");46 By result = converter.convert(By.xpath(xpath));47 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");48 }49 @Test50 public void testWebTextLocatorWithDoubleQuotesAndContains() {51 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);52 String xpath = "//div[contains(text(), \"Text text\")]";53 By expectedRes = By.xpath(54 "//div[contains(translate(text(), \"TEXT TEXT\", \"text text\"),translate(\"Text text\", \"TEXT TEXT\", \"text text\"))]");55 By result = converter.convert(By.xpath(xpath));56 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");57 }58 @Test59 public void testWebTextLocatorWithQuoteInText() {60 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);61 String xpath = "//div[contains(text(), \"Text's text\")]";62 By expectedRes = By.xpath(63 "//div[contains(translate(text(), \"TEXT'S TEXT\", \"text's text\"),translate(\"Text's text\", \"TEXT'S TEXT\", \"text's text\"))]");64 By result = converter.convert(By.xpath(xpath));65 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");66 }67 @Test68 public void testWebTextLocatorWithQuoteAndDollarSymbolInText() {69 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);70 String xpath = "//div[text() = 'Text text$169,90']";71 By expectedRes = By.xpath(72 "//div[translate(text(), 'TEXT TEXT$169,90', 'text text$169,90')=translate('Text text$169,90', 'TEXT TEXT$169,90', 'text text$169,90')]");73 By result = converter.convert(By.xpath(xpath));74 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");75 }76 @Test77 public void testWebTextLocatorWithDoubleQuoteAndDollarSymbolInText() {78 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);79 String xpath = "//div[text() = \"Text text$169,90\"]";80 By expectedRes = By.xpath(81 "//div[translate(text(), \"TEXT TEXT$169,90\", \"text text$169,90\")=translate(\"Text text$169,90\", \"TEXT TEXT$169,90\", \"text text$169,90\")]");82 By result = converter.convert(By.xpath(xpath));83 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");84 }85 @Test86 public void testComplexWebTextLocator() {87 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);88 String xpath = "//div[@class = 'someClass']/../..//h5[contains(text(), 'Text text')]//span[contains(@class, 'someClass')]";89 By expectedRes = By.xpath(90 "//div[@class = 'someClass']/../..//h5[contains(translate(text(), 'TEXT TEXT', 'text text'),translate('Text text', 'TEXT TEXT', 'text text'))]//span[contains(@class, 'someClass')]");91 By result = converter.convert(By.xpath(xpath));92 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");93 }94 @Test95 public void testComplexWebTextLocatorWithQuoteInText() {96 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);97 String xpath = "//div[@class = 'someClass']/../..//h5[contains(text(), \"Text's text\")]//span[contains(@class, 'someClass')]";98 By expectedRes = By.xpath(99 "//div[@class = 'someClass']/../..//h5[contains(translate(text(), \"TEXT'S TEXT\", \"text's text\"),translate(\"Text's text\", \"TEXT'S TEXT\", \"text's text\"))]//span[contains(@class, 'someClass')]");100 By result = converter.convert(By.xpath(xpath));101 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");102 }103 @Test104 public void testTextLocatorWithS() {105 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, true, false), Platform.WEB);106 String xpath = "//*[contains(text(), \"%s\")]";107 By expectedRes = By.xpath("//*[contains(translate(text(), \"%s\", \"%s\"),translate(\"%s\", \"%s\", \"%s\"))]");108 By result = converter.convert(By.xpath(xpath));109 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");110 }111 @Test112 public void testId() {113 LocatorConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(true, false, false, false), Platform.WEB);114 String xpath = ".//*[@id='some id']";115 By expectedRes = By.xpath(116 ".//*[translate(@id, 'SOME ID', 'some id')=translate('some id', 'SOME ID', 'some id')]");117 By result = converter.convert(By.xpath(xpath));118 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");119 }120 @Test121 public void testClass() {122 CaseInsensitiveConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, false, true), Platform.WEB);123 String xpath = "//md-icon[@class='example-class ExAmPLe-cLASS-2']";124 By expectedRes = By.xpath(125 "//md-icon[translate(@class, 'EXAMPLE-CLASS EXAMPLE-CLASS-2', 'example-class example-class-2')=translate('example-class ExAmPLe-cLASS"126 + "-2', 'EXAMPLE-CLASS EXAMPLE-CLASS-2', 'example-class example-class-2')]");127 By result = converter.convert(By.xpath(xpath));128 System.out.println(result);129 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");130 }131 @Test132 public void testName() {133 CaseInsensitiveConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, true, false, false), Platform.WEB);134 String xpath = "//md-icon[@name='example-class ExAmPLe-cLASS-2' and @class=\"some class\"]";135 By expectedRes = By.xpath(136 "//md-icon[translate(@name, 'EXAMPLE-CLASS EXAMPLE-CLASS-2', 'example-class example-class-2')=translate('example-class ExAmPLe-"137 + "cLASS-2', 'EXAMPLE-CLASS EXAMPLE-CLASS-2', 'example-class example-class-2') and @class=\"some class\"]");138 By result = converter.convert(By.xpath(xpath));139 Assert.assertEquals(result, expectedRes, "Incorrect converting to caseinsensitive xpath!");140 }141}...

Full Screen

Full Screen

Source:LocatorConvertingMobileTest.java Github

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.locator;2import org.openqa.selenium.By;3import org.testng.Assert;4import org.testng.annotations.Test;5import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;6import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.ParamsToConvert;7import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.Platform;8public class LocatorConvertingMobileTest {9 private final CaseInsensitiveConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, false, false), Platform.MOBILE);10 @Test11 public void convertIdToXpathTest() {12 By idLocator = By.id("some_id");13 By expectedRes = By.xpath(14 "//*[ends-with(@resource-id, ':id/some_id')]");15 By result = converter.convert(idLocator);16 Assert.assertEquals(result, expectedRes, "Incorrect converting to xpath!");17 }18 @Test19 public void convertNameToXpathTest() {20 By nameLocator = By.name("some_name");21 By expectedRes = By.xpath(22 "//*[@name='some_name']");23 By result = converter.convert(nameLocator);...

Full Screen

Full Screen

Source:LocatorConvertingWebTest.java Github

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.locator;2import org.openqa.selenium.By;3import org.testng.Assert;4import org.testng.annotations.Test;5import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;6import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.ParamsToConvert;7import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.Platform;8public class LocatorConvertingWebTest {9 private final CaseInsensitiveConverter converter = new CaseInsensitiveConverter(new ParamsToConvert(false, false, false, false), Platform.WEB);10 @Test11 public void convertIdToXpathTest() {12 By idLocator = By.id("some_id");13 By expectedRes = By.xpath(14 ".//*[@id='some_id']");15 By result = converter.convert(idLocator);16 Assert.assertEquals(result, expectedRes, "Incorrect converting to xpath!");17 }18 @Test19 public void convertNameToXpathTest() {20 By nameLocator = By.name("some_name");21 By expectedRes = By.xpath(22 ".//*[@name='some_name']");23 By result = converter.convert(nameLocator);...

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.gui.pages;2import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedElement;3import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedElementLocatorFactory;4import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedFieldDecorator;5import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;6import org.openqa.selenium.By;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.support.FindBy;9import org.openqa.selenium.support.PageFactory;10import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;11import org.openqa.selenium.support.pagefactory.FieldDecorator;12public class HomePage {13 private ExtendedElement header;14 private ExtendedElement loginButton;15 private ExtendedElement registerButton;16 private ExtendedElement cartButton;17 private ExtendedElement wishlistButton;18 private ExtendedElement compareButton;19 private ExtendedElement accountButton;20 private ExtendedElement searchButton;21 private ExtendedElement searchField;22 private ExtendedElement searchSubmitButton;23 private ExtendedElement logoutButton;24 private ExtendedElement loginLink;25 private ExtendedElement registerLink;26 private ExtendedElement cartLink;27 private ExtendedElement wishlistLink;28 private ExtendedElement compareLink;

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.locator;2import java.lang.reflect.Method;3import org.openqa.selenium.By;4import org.openqa.selenium.SearchContext;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.support.pagefactory.ElementLocator;7public class CaseInsensitiveElementLocator implements ElementLocator {8 private final SearchContext searchContext;9 private final boolean shouldCache;10 private final By by;11 private WebElement cachedElement;12 private java.util.List<WebElement> cachedElementList;13 public CaseInsensitiveElementLocator(SearchContext searchContext, Method method) {14 this.searchContext = searchContext;15 CaseInsensitiveBy by = method.getAnnotation(CaseInsensitiveBy.class);16 this.by = by.value();17 this.shouldCache = by.cache();18 }19 public WebElement findElement() {20 if (cachedElement != null && shouldCache) {21 return cachedElement;22 }23 WebElement element = searchContext.findElement(by);24 if (shouldCache) {25 cachedElement = element;26 }27 return element;28 }29 public java.util.List<WebElement> findElements() {30 if (cachedElementList != null && shouldCache) {31 return cachedElementList;32 }33 java.util.List<WebElement> elements = searchContext.findElements(by);34 if (shouldCache) {35 cachedElementList = elements;36 }37 return elements;38 }39}40package com.qaprosoft.carina.core.foundation.webdriver.locator;41import java.lang.annotation.ElementType;42import java.lang.annotation.Retention;43import java.lang.annotation.RetentionPolicy;44import java.lang.annotation.Target;45import org.openqa.selenium.By;46@Retention(RetentionPolicy.RUNTIME)47@Target(ElementType.METHOD)48public @interface CaseInsensitiveBy {49 By value();50 boolean cache() default true;51}52package com.qaprosoft.carina.core.foundation.webdriver.locator;53import java.lang.reflect.Field;54import org.openqa.selenium.SearchContext;55import org.openqa.selenium.support.pagefactory.Annotations;56import org.openqa.selenium.support.pagefactory.ElementLocator;57import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;58public class CaseInsensitiveFactory implements ElementLocatorFactory {

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1import java.util.List;2import org.openqa.selenium.By;3import org.openqa.selenium.WebElement;4import org.testng.Assert;5import org.testng.annotations.Test;6import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;7import com.qaprosoft.carina.core.foundation.webdriver.locator.LocatorType;8import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;9import com.qaprosoft.carina.core.foundation.webdriver.locator.convertor.LocatorConvertor;10import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;11import com.qaprosoft.carina.core.gui.AbstractPage;12import com.qaprosoft.carina.core.gui.AbstractUIObject;13{14 public CaseInsensitiveConverterExample(WebDriver driver)15 {16 super(driver);17 }18 public WebElement getWebElement(String locator, LocatorType type) 19 {20 LocatorConvertor convertor = new CaseInsensitiveConverter();21 locator = convertor.convert(locator, type);22 return getDriver().findElement(By.xpath(locator));23 }24 public List<WebElement> getWebElements(String locator, LocatorType type) 25 {26 LocatorConvertor convertor = new CaseInsensitiveConverter();27 locator = convertor.convert(locator, type);28 return getDriver().findElements(By.xpath(locator));29 }30 public ExtendedWebElement getExtendedWebElement(String locator, LocatorType type) 31 {32 LocatorConvertor convertor = new CaseInsensitiveConverter();33 locator = convertor.convert(locator, type);34 return new ExtendedWebElement(getDriver().findElement(By.xpath(locator)), getDriver());35 }36 public List<ExtendedWebElement> getExtendedWebElements(String locator, LocatorType type) 37 {38 LocatorConvertor convertor = new CaseInsensitiveConverter();39 locator = convertor.convert(locator, type);40 List<WebElement> webelements = getDriver().findElements(By.xpath(locator));41 List<ExtendedWebElement> extendedWebelements = new ArrayList<ExtendedWebElement>();42 for(WebElement element: webelements)43 {44 extendedWebelements.add(new ExtendedWebElement(element, getDriver()));45 }46 return extendedWebelements;47 }48 public AbstractUIObject getUIObject(String locator, LocatorType type) 49 {

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;2import org.openqa.selenium.By;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.remote.RemoteWebDriver;5import org.openqa.selenium.support.ui.ExpectedConditions;6import org.openqa.selenium.support.ui.WebDriverWait;7public class CaseInsensitiveConverterTest {8 public static void main(String[] args) {9 RemoteWebDriver driver = new RemoteWebDriver();10 WebDriverWait wait = new WebDriverWait(driver, 15);11 WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(12 CaseInsensitiveConverter.convertToXpath(By.cssSelector("input[name='q']"))));13 element.sendKeys("test");14 }15}16import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;17import org.openqa.selenium.By;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.remote.RemoteWebDriver;20import org.openqa.selenium.support.ui.ExpectedConditions;21import org.openqa.selenium.support.ui.WebDriverWait;22public class CaseInsensitiveConverterTest {23 public static void main(String[] args) {24 RemoteWebDriver driver = new RemoteWebDriver();25 WebDriverWait wait = new WebDriverWait(driver, 15);26 WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(27 CaseInsensitiveConverter.convertToXpath(By.cssSelector("input[name='q']"))));28 element.sendKeys("test");29 }30}31import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;32import org.openqa.selenium.By;33import org.openqa.selenium.WebElement;34import org.openqa.selenium.remote.RemoteWebDriver

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Carina automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful