How do i scroll down to an element in Katalon? - testing

I am unable to scroll down to the save button at the end of the page. Have tried using scrollToElement function but it does not work.
The error given :
Test Cases/merchantAdd1 FAILED because (of) groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.scrollToElement() is applicable for argument types: (com.kms.katalon.core.testobject.TestObject)

This doesn't necessarily mean you are unable to scroll to an element. You are missing a parameter.
The error message is saying you are trying to pass the wrong types of argument to scrollToElement() function. It is expecting a TestObject and an int (timeout in seconds) and you are passing in only the test object.
It should be something like
WebUI.scrollToElement(findTestObject('your test object'), 3)

If you are unable to find Test Object, and it is at the bottom of the page, try scrolling to position high absisse and ordinate.
for example WebUI.scrollToPosition(9999999, 9999999)
Then try click on the Objct

Related

Problem locating element with xpath in Selenium

I am having some troubles to locate an element with Selenium.
The page html where I'm looking for it is:
enter image description here
Specifically, I want to get the input with id='filtroDNI'. For this I'm using
WaitFluent.xpathClickable("//input[#id='filtroDNI']")
But I'm getting Method threw 'org.openqa.selenium.TimeoutException' exception. because Expected condition failed: waiting for visibility of element located by By.xpath: //input[#id='filtroDNI'] (tried for 11 second(s) with 3000 milliseconds interval)
However, If I try to get some elements above this one, I can reach the div with id='content-wrap' by using following code:
WaitFluent.xpathClickable("//div[#id='content-wrap']")
Do you have any idea of what can be happening? Also I tried with alternative xpaths but the results are the same.
Also, the page is throwing an error but after consulting it with the dev team, they said it has nothing to be with my question, the error is this one:
Uncaught TypeError: Cannot read properties of undefined (reading 'hasChildNodes')
at sorter.sort (script.js:53:12)
at sorter.reset (script.js:43:9)
at sorter.init (script.js:37:8)
at new sorter (script.js:8:77)
at histo.php:277:54
Thanks in advance
Edit:
xpathClickable method code:
/**
* <STRONG>Description:</STRONG>Waits for an element with a given xpath to be clickable.
*
* #param xpath String;
* #return WebElement
*/
public static WebElement xpathClickable(final String xpath) {
return new FluentWait<WebDriver>(myEnvironment)
.withTimeout(IMPLICIT_TIMEOUT)
.pollingEvery(RETRY_TIME)
.ignoring(StaleElementReferenceException.class,
NoSuchElementException.class)
.until(ExpectedConditions
.elementToBeClickable(By.xpath(xpath)));
}
Edit 2:
DEV team already solved the JS issue shown in console, but the xpath cannot be retrieved yet.

How to use resource id in Appium

I am testing a mobile app which doesn't have right set locators in it, so i can use only "resource-id"
from appium.webdriver.common.appiumby import AppiumBy
# Locators
profile_btn = (AppiumBy.ID, 'io.dzain.dzain.uat:id/navItemIV')
profile_btn.click()
When I run this code following error message is displayed
AttributeError: 'tuple' object has no attribute 'click'
How can i use the resource-id to handle this problem?
You call clicks on the appium/webdriver elements returned from the driver, something like so:
profile_btn = self.driver.find_element(AppiumBy.ID, 'io.dzain.dzain.uat:id/navItemIV')
profile_btn.click()
You feed your by method and your element locator definition into the find_element function and call clicks on the element object it returns to you.

InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression contains(text() error message

I'm getting this error message when selenium/C# program tried to click on an element in a drop down list in Dynamis365.
Inner Exception 1:
InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression contains(text(), 'Submitted') because of the following error:
TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type.
(Session info: chrome=87.0.4280.88)
My Code is:
internal void SetValues()
{
findByElement.FindByXPath("//span[contains(text(), 'Submission Pending')]").Click();
findByElement.FindByXPath("contains(text(), 'Submitted')").Click();
}
The HTML is:
<span id="id-bc19d003-2d6a-43ad-8e1b-566ecbb00647-132-statuscode6-statuscode.fieldControl-pickliststatus-comboBox_text-value" class=" ">Submission Pending</span>
I'm trying to click on Submitted choice, which do not show in HTML:DropDownList
Note: The other drop down list choices do not show in html. Only after making a choice (Submitted) it shows up in the html (replaces Submission Pending")
Submission Pending
Submitted clicked
Are you sure the page has fully loaded? Have you read the docs, specifically the 'waits' section (link below for the python version). I had this problem and simply put a 5 second delay into the code and it worked fine.
https://selenium-python.readthedocs.io/waits.html
Alternatively you may find it easier locating the element by id rather than by XPath
FindByXPath("contains(text(), 'Submitted')")
This is not a valid XPath expression! All XPath must start with the slash / character. Perhaps you meant something like:
FindByXPath("//*[contains(text(), 'Submitted')]")
Below line of code worked:
findByElement.FindByXPath("//*[./text()='Submitted']").Click();

Selenium script getting error 'value cannot be null parameter: source' after setting password textbox

I am getting an error "Value cannot be null,parameter name: s" after setting password through selenium script and clicking submit button.
Please help me on this, Thanks
Am using the below code for setting password
var passwordtxt=driver.FindElement(By.Id("txtpassword"));
var JSexecutor= (IJavaScriptExecutor)driver;
JSexecutor.ExecuteScript("arguments[0].setAttribute('value', arguments[1])",passwordtxt,"mypassword");
Based on the error message you provided, it sounds like the item passwordtxt doesn't exist on the page. Value cannot be null is referring to the element you pass into ExecuteScript, which is passwordtxt in this case.
To solve this problem, you will need to change the way you are finding passwordtxt. If you post some more HTML from your page's source, we can help you determine the correct selector to use.

AppleScript not getting URL or webpage title in Safari

I am trying to do the following in Safari: I have a website opened (let's say http://www.example.org) and I'm trying to get the current tab by using applescript.
I tried the following:
delay 1
tell application "Safari"
set mytitle to name of current tab in window 1
end tell
display alert mytitle
However I get the following error message
Safari got an error: AppleEvent handler failed.
I tried with all sorts of variations, URL of current tab in window 1, name of current tab, with and without window 1...
But the error persists.
After a bit of consoling it came up with this error:
Console returns this: Error while returning the result of a script command: the result object... lol - Buscar con Google ...could not be converted to an Apple event descriptor of type 'text'. This instance of the class '__NSCFString' returned nil when sent -objectSpecifier (is it not overridden?) and there is no coercible type declared for the scripting class 'text'.
What am I doing wrong?
I'd appreciate any ideas.
Thanks.
Try:
tell application "Safari"
set mytitle to name of current tab in window 1
end tell
return mytitle
The first script I posted did indeed work... There was a systemwide error and clean install fixed it. Not sure what was going on. Thanks everyone.