UI Testing failure - No matches found for SearchField - xcode7

My XCode recorded UI test fails on the second line:
XCUIElement *musicselectviewNavigationBar = app.navigationBars[#"MusicSelectView"];
[[musicselectviewNavigationBar.otherElements childrenMatchingType:XCUIElementTypeSearchField].element tap];
[[musicselectviewNavigationBar.searchFields containingType:XCUIElementTypeButton identifier:#"Clear text"].element typeText:#"Lean"];
Upon testing I get this error:
UI Testing failure - No matches found for "MusicSelectView" NavigationBar
Ideas?

Access the search bar directly instead of using the recorded path.
[app.searchFields[#"Clear text"] tap];
[app.searchFields[#"Clear text"] typeText:#"Lean"];
If there is only one search field present, you can access it with element.
[[app.searchFields element] tap];
[[app.searchFields element] typeText:#"Lean"];

check what you have at line 1 in app.navigationBars
set your navigation bar accessibilityIdentifier to #"MusicSelectView"
access your navigation bar with matchingIdentifier:#"MusicSelectView" method call

Related

unable to find multiple existing element with selenium

here is the html code of the Links i am trying to click on (i dont know why selenium cant locate the link. My guess is, that there are X amounts of the link. The only difference is the string in the brackets of onclick.) Underneath i'll show you 2 examples of the html code. I'd like to click on all of them (in this case on both)!
Button or Link:
<td class="text-right">
Ansehen</td>
Button or Link:
<td class="text-right">
Ansehen</td>
here are my Attempts to click on the button:
driver.find_element_by_link_text("doRetrievePnr('DUA75J')").click()
driver.find_element_by_xpath("//a[#onclick='doRetrievePnr('DUA75J')']").click()
Here are the Errors i get:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"doRetrievePnr('DUA75J')"}
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //a[#onclick='doRetrievePnr('DUA75J')'] because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//a[#onclick='doRetrievePnr('DUA75J')']' is not a valid XPath expression.
am I missing out on something?
EDIT
Heres a picture of the BUTTONS, the HTML CODE and my PYTHON CODE (lines 34 & 35)
As mentioned in the comments - getting all the items of a specific identifier can be done with find_elements_by_... (note find elements - it's plural)
That returns an array you can iterate through to interact with each element.
It looks like all your links have the same ID.
Something like this might work:
links = driver.find_elements_by_id('viewPnr')
for link in links:
link.click()
time.sleep(10) #replace this with what you want to do
Obviously if you're clicking links and the page changes this might not work after the first iteration. However, this is the concept on how you can get all objects and iterate through them.

When I use MainWindow.hide() funtion, it gives me an error stating MainWindow is not defined but same MainWindow works in setupUI and retranslateUI

I am fairly new to PyQt5. So here, I am trying to work on a project in which first window in login page dialog window. So if password entered are correct it will open another window.
def login(self):
eid=self.lineEdit.text()
epass=self.lineEdit_2.text()
if eid==idd and epass==passs:
from BloodBank import Ui_MainWindow
self.MainWindow = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow()
self.ui.setupUi(self.MainWindow)
LoginPage.hide()
self.MainWindow.show()
else:
self.msgdlg("Wrong ID or Password!")
In this Window, from title bar menu action, I tried to attach yet another window, which when opened, current window become hidden. For this I wrote following code:
def menu(self,action):
txt=(action.text())
if txt=="Blood":
try:
from Blood import Ui_MainWindow
self.MainWindow1 = QtWidgets.QMainWindow()
self.ui = Ui_MainWindow()
self.ui.setupUi(self.MainWindow1)
MainWindow.hide()
self.ui.updatelist()
self.MainWindow1.show()
except Exception as e:
print(e)
Now, When I run above code without MainWindow.hide() it run perfectly fine. But as soon as I feed MainWindow.hide() it gives following error.
name 'MainWindow' is not defined
When I try same .hide() funtion with login page, it works.
What do I need to do so I can hide my window?
Your code is a bit unclear, but i think it should be self.MainWindow.hide() because we are trying to hide our parent widget.
Edit
Try self.hide() in the bloodbank file instead of MainWindow.hide() I am assuming that in the file bloodbank you have your mainwindow.
Here is the problem, you have two files the Login File which consists of the loginpage and the bloodbank file.
when you created a the instance of self.MainWindow it is only in the namespace of the loginpage.
And you try to open a another window from this file (which is the 2nd part of your code). MainWindow instance is not present because you have defined (instantiated) in another file (login page).

Unknown "non-finite double value" Javascript error being thrown

I ran into the following error while doing actions.moveToElement(ele).click().build().perform() :
javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.
Some searches showed people in Chrome Mobile or other products receiving that, but I am just using the regular ChromeDriver (78) version with Java. They said it is fixed in a product I am not using.
Has anyone had this in the regular Chrome Driver?
I found that the cause of me seeing this error was that the element I was trying to click was a <title> meta data element. My original code picked an element to click using the visible text on the page:
var element = driver.FindElement(By.XPath("//*[contains(text(), '" + text + "')]"));
new Actions(this.Driver)
.MoveToElement(element, 1, 1)
.Click()
.Perform();
However, this text also existed in the title of the browser so the returned element was actually a <title> metadata element. I haven't created this element, only set document.title so somewhat surprised to see it all. I don't think this was past behaviour or was it...?
My fix was to exclude title elements in my xpath query:
var element = driver.FindElement(By.XPath("//*[not(self::title) and contains(text(), '" + text + "')]"))
Note that with the firefox driver, this error surfaces as rect is undefined.

Using groovy script on Katalon to click on row of grid

With groovy script on Katalon, I want to click on first row of grid but it is not working and it shows error (error.png with Option1 mentioned below) in console.
I have tried by targeting different element's xpath of row but it seems click() event is not being recognized. Also, added wait and waitForPresentElement but did not work.
Following are three options I tried so far but none of them worked.
Groovy on Katalon:
Option 1:
WebUiCommonHelper.findWebElement(By.xpath("//div[#class='dgrid-row dgrid-row-even ui-state-default']/table/tr/td/span[#class='dijitIconFlag dijitFixedMatterIcon']")).click()
Option 2:
WebUiCommonHelper.findWebElement(By.xpath("//div[#class='dgrid-row dgrid-row-even ui-state-default']/table/tr/td[contains(#class,'dgrid-cell dgrid-cell-padding dgrid-column-0-')]").click()
Option3:
WebUI.click(findTestObject('Object Repository/Page_Law Practice Management Software CosmoLex/td_Client Funds-Trust_dgrid-cell dgrid-cell_865aa6'))
Source code:
Source code is in xPath.jpg.
Expected:
The row should be selected/clicked.
//table[#class="dgrid-row-table"]//tr//td
Use this as xpath,
and click by this manner.
Hope it will help you.
List<WebElement> objects = WebUiCommonHelper.findWebElements(findTestObject('***put xpath url here***'), 30)
WebUI.delay(1)
objects.get(0).click()

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

I'm programming for fun so I wanted to learn about selenium webdriver using twitter but I have a problem.
The problem comes when I try to put my text in the box of the tweet:
So I have to kind of activate the element that's on the box and that went good:
TBot = webdriver.Chrome()
twitter_box_act = Tbot.find_element_by_xpath('//div[#class="public-DraftEditorPlaceholder-inner"]')
Tbot.execute_script("arguments[0].click(), twitter_box_act)
But once i try to put some text on the box this error appears:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
The code that I've used to try to put text on the box is the next:
tweet_entry = self.bot.find_element_by_xpath('//span[#data-text="true"]')
tweet_entry.send_keys("some text here")
So what I've tried is looking more deep in the code with F12 this is what I got:
I tried to put some time.sleep(x) between every step that didn't solve it.
I tried editing first the br tag and after that editing the span tag but I still had the same message error
I've been looking on the internet with Twitter projects with selenium as well but since they change the UI is not the same HTML body.
Am I missing something?
PS: I skipped the login part since that has nothing to do with the problem
You have tried change this line:
-->Tbot.execute_script("arguments[0].click(), twitter_box_act)
The error is for interactable, and you has interable in arguments.