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

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.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

1import org.openqa.selenium.By;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.chrome.ChromeDriver;5import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;6public class CaseInsensitiveDemo {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Dell\\Downloads\\chromedriver_win32\\chromedriver.exe");9 WebDriver driver = new ChromeDriver();10 searchBox.sendKeys("Selenium");11 searchBox.submit();12 driver.quit();13 }14}

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.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.chrome.ChromeDriver;6public class CaseInsensitiveTest {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");9 WebDriver driver = new ChromeDriver();10 searchBox.click();11 }12}13public abstract String convert(String locator);14public abstract String convert(String locator, String... args);15import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.AbstractLocatorConverter;16import org.openqa.selenium.By;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.chrome.ChromeDriver;20public class CustomTest {21 public static void main(String[] args) {22 System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");23 WebDriver driver = new ChromeDriver();24 searchBox.click();25 }26}27class CustomLocatorConverter extends AbstractLocatorConverter {28 public String convert(String locator) {29 return locator;30 }31 public String convert(String locator, String... args) {32 return String.format(locator, (Object[]) args);33 }34}35import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;36import com.qaprosoft.carina.core.foundation.webdriver.loc

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.gui.pages;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.support.FindBy;4import org.openqa.selenium.support.PageFactory;5import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;6import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;7import com.qaprosoft.carina.core.gui.AbstractPage;8public class HomePage extends AbstractPage {9 private ExtendedWebElement contactUsButton;10 public HomePage(WebDriver driver) {11 super(driver);12 PageFactory.initElements(driver, this);13 }14 public boolean isPageOpened() {15 return contactUsButton.isPresent();16 }17}18package com.qaprosoft.carina.demo.gui.pages;19import org.openqa.selenium.WebDriver;20import org.openqa.selenium.support.FindBy;21import org.openqa.selenium.support.PageFactory;22import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;23import com.qaprosoft.carina.core.foundation.webdriver.locator.strategy.CaseInsensitiveStrategy;24import com.qaprosoft.carina.core.gui.AbstractPage;25public class HomePage extends AbstractPage {26 private ExtendedWebElement contactUsButton;27 public HomePage(WebDriver driver) {28 super(driver);29 PageFactory.initElements(driver, this);30 }31 public boolean isPageOpened() {32 return contactUsButton.isPresent();33 }34}35package com.qaprosoft.carina.demo.gui.pages;36import org.openqa.selenium.WebDriver;37import org.openqa.selenium.support.FindBy;38import org.openqa.selenium.support.PageFactory;39import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;40import com.qaprosoft.carina.core.foundation.webdriver.locator.strategy.CaseInsensitiveStrategy;41import com.qaprosoft.carina.core.gui.AbstractPage;42public class HomePage extends AbstractPage {43 private ExtendedWebElement contactUsButton;44 public HomePage(WebDriver driver) {45 super(driver);

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1public class CaseInsensitiveConverterTest {2 private static final Logger LOGGER = Logger.getLogger(CaseInsensitiveConverterTest.class);3 private static final String TEXT = "Hello World";4 private static final String SEARCH_FIELD = "q";5 private static final String SEARCH_BUTTON = "btnK";6 private static final String SEARCH_RESULT = "div.g";7 private static final String SEARCH_RESULT_URL = "div.g div.r a";8 private static final String SEARCH_RESULT_URL_TEXT = "div.g div.r a h3";9 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE = "div.g div.r a h3";10 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_2 = "div.g div.r a h3";11 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_3 = "div.g div.r a h3";12 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_4 = "div.g div.r a h3";13 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_5 = "div.g div.r a h3";14 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_6 = "div.g div.r a h3";15 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_7 = "div.g div.r a h3";16 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_8 = "div.g div.r a h3";17 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_9 = "div.g div.r a h3";18 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_10 = "div.g div.r a h3";19 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_11 = "div.g div.r a h3";20 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_12 = "div.g div.r a h3";21 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_13 = "div.g div.r a h3";22 private static final String SEARCH_RESULT_URL_TEXT_CASE_INSENSITIVE_14 = "div.g div.r a h3";

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;2public class 1 {3 public static void main(String[] args) {4 String convertedLocator = CaseInsensitiveConverter.convert(locator);5 System.out.println(convertedLocator);6 }7}8import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;9public class 2 {10 public static void main(String[] args) {11 String convertedLocator = CaseInsensitiveConverter.convert(locator, "id");12 System.out.println(convertedLocator);13 }14}15import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;16public class 3 {17 public static void main(String[] args) {18 String convertedLocator = CaseInsensitiveConverter.convert(locator, "css");19 System.out.println(convertedLocator);20 }21}

Full Screen

Full Screen

CaseInsensitiveConverter

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.webdriver.locator;2import java.lang.reflect.Field;3import org.apache.log4j.Logger;4import org.openqa.selenium.By;5import org.openqa.selenium.support.pagefactory.Annotations;6import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;7import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveXpathConverter;8{9 private static final Logger LOGGER = Logger.getLogger(CaseInsensitiveLocatorFactory.class);10 public CaseInsensitiveLocatorFactory(CustomElementLocatorFactory factory)11 {12 super(factory);13 }14 public By createLocator(Field field)15 {16 if (field.isAnnotationPresent(CaseInsensitive.class))17 {18 CaseInsensitive caseInsensitive = field.getAnnotation(CaseInsensitive.class);19 if (caseInsensitive.type().equals(CaseInsensitiveType.XPATH))20 {21 return new CaseInsensitiveXpathConverter().apply(new Annotations(field).buildBy());22 }23 if (caseInsensitive.type().equals(CaseInsensitiveType.CSS))24 {25 return new CaseInsensitiveConverter().apply(new Annotations(field).buildBy());26 }27 }28 return super.createLocator(field);29 }30}31package com.qaprosoft.carina.core.foundation.webdriver.locator;32import java.lang.reflect.Field;33import org.apache.log4j.Logger;34import org.openqa.selenium.By;35import org.openqa.selenium.support.pagefactory.Annotations;36import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveConverter;37import com.qaprosoft.carina.core.foundation.webdriver.locator.converter.caseinsensitive.CaseInsensitiveXpathConverter;38{39 private static final Logger LOGGER = Logger.getLogger(CaseInsensitiveLocatorFactory.class);40 public CaseInsensitiveLocatorFactory(CustomElementLocatorFactory factory

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.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful