Hi Team,
I facing the issue to click on a link inside the web table.
So previously I used the actions method to click on the link, But now it is not working because of a recent update from SalesForce and their tooltips.
Below is the script
import org.junit.After as After
import org.openqa.selenium.By as By
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.openqa.selenium.interactions.Actions as Actions
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import com.kms.katalon.core.testdata.reader.ExcelFactory as ExcelFactory
import java.awt.Robot as Robot
import java.awt.event.KeyEvent as KeyEvent
import com.kms.katalon.core.webui.common.WebUiCommonHelper
//getting the data from excel******************************************************************************
Object excelData = ExcelFactory.getExcelDataWithDefaultSheet(‘D:\Manual_Testcases\Billing Contacts - CFT_Review 06-2021 QA.xlsx’,
'Contacts-Full', true)
WebUI.callTestCase(findTestCase(‘WebApp/Salesforce_CRM/Login/Login To CRM_UAT’), [:], FailureHandling.STOP_ON_FAILURE)
String Usertype
Usertype = ‘institutional’
WebDriver driver1 = DriverFactory.getWebDriver()
WebDriver driver = com.kms.katalon.core.webui.driver.DriverFactory.getWebDriver()
for (int i = 1; i <= excelData.getRowNumbers(); i++) {
String excelvalue = excelData.getValue('Client ID (QFM)', i)
println(excelvalue)
if (Usertype == 'institutional') {
CustomKeywords.'web_Functions.SelectingAccount.AccountSelecting'(excelvalue)
WebUI.waitForElementPresent(findTestObject('WebApp/CRM/More/More_button'), 30)
WebUI.click(findTestObject('WebApp/CRM/More/More_button'))
WebUI.delay(10)
WebUI.waitForElementPresent(findTestObject('WebApp/CRM/Documents/Documents'), 30)
WebUI.click(findTestObject('WebApp/CRM/Documents/Documents'))
WebUI.delay(10)
WebUI.delay(2)
WebElement table = driver.findElement(By.xpath('//table[contains(@class,"slds-table slds-table_bordered slds-table_cell-buffer slds-table_fixed-layout-media cDocumentsList")]'))
List<WebElement> tr_count = table.findElements(By.tagName('tr'))
println(tr_count.size())
List<WebElement> td_Count = tr_count.get(1).findElements(By.tagName('td'))
String file_Name_CRM = td_Count.get(0).getText()
println(file_Name_CRM)
Here i got the link name( println(file_Name_CRM)) but click action is not working.I need to click on “(td_Count.get(0))” this link.
//Facing issue here*********************************************************************************************************************************************
WebUI.waitForElementVisible(findTestObject(‘WebApp/CRM/Invoice/File_OR/a_Alberta Carpenters and Allied Workers Pension Plan_58692_00000024983_06302021 (2).pdf’),
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript(“td_Count.get(0).focus(); td_Count.get(0).click()”,WebUI.click(findTestObject(‘WebApp/CRM/Invoice/File_OR/a_Alberta Carpenters and Allied Workers Pension Plan_58692_00000024983_06302021 (2).pdf’),
30));
//WebUI.executeJavaScript('''document.querySelector('a[href="/lightning/o/Account/home"] > span').click()''', tr_count)
//WebUI.click(findTestObject('WebApp/CRM/Invoice/File_OR/a_Alberta Carpenters and Allied Workers Pension Plan_58692_00000024983_06302021 (2).pdf'))
//WebElement ele = driver.findElement(By.xpath(‘//*[@id=“tab-9”]/slot/flexipage-component2/slot/flexipage-aura-wrapper/div/article/div[2]/table/tbody/tr[1]/td[1]/a’));
//JavascriptExecutor executor = (JavascriptExecutor)driver;
//executor.executeScript(“td_Count.get(0.click();”, ele);
//***********************************************************************************************
//java.util.List yourVar = WebUiCommonHelper.findWebElements(findTestObject(“Alberta Carpenters and Allied Workers Pension Plan_58692_00000024983_06302021 (2).pdf”), 30)
//yourVar(0).click
//String js = ‘document.querySelector(//a[contains(text(),“Alberta Carpenters and Allied Workers Pension Plan_58692_00000024983_06302021 (2).pdf”)]).click();’
//WebUI.executeJavaScript(js, null)
//WebDriver driver = DriverFactory.getWebDriver()
//JavascriptExecutor jse = (JavascriptExecutor)driver;
//jse.executeScript(javascript)
//Robot rb = new Robot()
//rb.keyPress(KeyEvent.VK_ENTER)
//WebUI.delay(1)
//rb.keyRelease(KeyEvent.VK_ENTER)
WebUI.delay(2)
Actions actions1 = new Actions(driver1)
actions1.click(td_Count.get(0)).perform()
//td_Count.get(4).click()
//WebUI.delay(10)
//List<WebElement> a_Count = td_Count.get(0).findElements(By.tagName('a'))
//println(a_Count.size())
//****************************************************************************************************************
//WebUI.click(findTestObject('//a[contains(@href,"javascript:void(0)")] [contains(text(),file_Name_CRM)]'))
//a_Count.get(0).click()
//def headerLogo = new TestObject('header_logo')
//headerLogo.addProperty('text()', ConditionType.EQUALS, file_Name_CRM)
//WebUI.click(headerLogo)
//TestObject toV = new TestObject()
//toV.addProperty('text()', ConditionType.EQUALS, file_Name_CRM)
//WebUI.doubleClick(toV)
//WebDriver driver = DriverFactory.getWebDriver()
//WebElement element = WebUiCommonHelper.findWebElement(to, timeout)
//JavascriptExecutor executor = ((driver) as JavascriptExecutor)
//executor.executeScript('a_Count.get(0)', element)
//WebUI.delay(20)
//WebDriver driver2 = DriverFactory.getWebDriver()
//WebUI.convertWebElementToTestObject(a_Count.get(0), FailureHandling.STOP_ON_FAILURE)
//WebElement element = WebUiCommonHelper.findWebElement(WebUI.(findTestObject('WebApp/CRM/Documents/Documents')), 10)
//JavascriptExecutor executor = ((driver2) as JavascriptExecutor)
//executor.executeScript('a_Count.get(0)', element)
//***************************************************************************************************************************
//*********************************************************************************************************************************************************
WebUI.delay(20)
}
if (Usertype == 'individual') {
CustomKeywords.'web_Functions.SelectingContact.contactSelecting'(excelvalue)
WebUI.delay(10)
WebUI.waitForElementPresent(findTestObject('WebApp/CRM/Contact/Documents'), 30)
WebUI.click(findTestObject('WebApp/CRM/Contact/Documents'))
WebUI.delay(10)
WebUI.delay(2)
WebElement table_Ind = driver.findElement(By.xpath('//table[contains(@class,"slds-table slds-table_bordered slds-table_cell-buffer slds-table_fixed-layout-media cDocumentsList")]'))
List<WebElement> tr_count_Ind = table_Ind.findElements(By.tagName('tr'))
println(tr_count_Ind.size())
List<WebElement> td_Count_Ind = tr_count_Ind.get(1).findElements(By.tagName('td'))
String file_Name_CRM_Ind = td_Count_Ind.get(0).getText()
//td_Count.get(0).click()
println(file_Name_CRM_Ind)
WebUI.delay(10)
List<WebElement> a_Count_Ind = td_Count_Ind.get(0).findElements(By.tagName('a'))
println(a_Count_Ind.size())
WebUI.delay(20)
Actions actions2 = new Actions(driver)
actions2.click(a_Count_Ind.get(0)).perform()
WebUI.delay(20)
}
String filename = CustomKeywords.'oldSprint_Package.Downloadingthefile.getLatestFilefromDir'('C:\\Users\\Swathi\\Downloads')
println(filename)
println(('C:\\Users\\Swathi\\Downloads' + '/') + filename)
CustomKeywords.'oldSprint_Package.FileOperations.Open_File'(('C:\\Users\\Swathi\\Downloads' + '/') + filename)
WebUI.delay(15)
String filepath = ('file:///' + ('C:\\Users\\Swathi\\Downloads' + '/')) + filename
String Strpagetext = CustomKeywords.'oldSprint_Package.ReadPDF.ReadPDF_Webpage'(filepath)
println(Strpagetext)
WebUI.delay(10)
}
println(excelData.getRowNumbers())
println(excelData.getSheetNames())
println(excelData.getColumnNames())
println(excelData.getColumnNumbers())
Appllication Screenshot:-
Thanks,
Swathi