Errore in Python con Selenium: TypeError - Oggetto di tipo 'str' non è richiamabile durante la ricerca di un

I encountered the error message: "TypeError: 'str' object is not callable" while running this code:

iframe=driver.find_element(By.XPATH("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]"));

What could be causing this issue?

Can someone provide the correct syntax for identifying an iframe?

Thank you.

I attempted to use:

iframe=driver.find_element(By.XPATH("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]"));

My expectation was to retrieve an iframe, however, instead I received an error.

I am trying to distinguish between two iframes that share the same class but have different src attributes.

Answer №1

To do this correctly: XPath should be written in lowercase

iframe=driver.find_element(By.xpath("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]"));

OR

iframe = driver.find_element_by_xpath("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]")

Answer №2

There are a few syntax errors in the following line of code:

iframe=driver.find_element(By.XPATH("//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]"));
Here is the corrected version:

iframe=driver.find_element(By.XPATH,"//iframe[contains(@src,'https://pianomarvel.com/uploads/editSlicings/85810')]")

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Keep an eye out for any instances of new files being created in nodemon js or npm

Is there a way to monitor only for new file creation events using nodemon js, npm, or any other packages? For instance, in a project, whenever a new file is created, a specific script needs to be executed to carry out additional tasks for a one-time setup. ...

Managing QComboBox wheel-events using an event-filter: Tips and tricks

In the latest version of Qt (Qt6), certain widgets such as QComboBox and QSpinBox may capture mouse wheel events that should be processed by their parent widget, like a QScrollArea. This occurs even when these widgets do not have focus, despite setting the ...

What is the best way to insert information into a complicated JSON dictionary using Python?

My task involves populating a JSON API Payload before sending it in the API request. The process includes working with 2 files: A text file containing JSON payload format, named json.txt A yml file containing actual data, named tdata.yml. I am developing ...

What is the interpretation of this error message and is there a solution I can apply to resolve

Utilizing the tweepy API, I am streaming specific information and saving it into a CSV. While tweets are being stored successfully, an error message keeps appearing: ('failed ondata', 'coercing to Unicode: need string or buffer, NoneType fou ...

Acquiring and implementing the result generated from a remotely executed script using subprocess.check_output

Struggling to articulate my issue in the title, I may not have done it justice. However, below is a detailed explanation of my current situation. I am open to suggestions for improving the title. Currently, I have two Raspberry Pi devices - Pi A serves as ...

Tips for updating a string in a Pandas column depending on a specific criteria?

I'm currently working on a task to verify if the values in a certain column are numbers and replace them with different strings. Below is the code snippet I am using: df["recs"] = ["45", "emp1", "12", "emp3", "emp4", "emp5"] recomm = df["recs"] # Chec ...

Filter rows in a pandas DataFrame based on the total sum of a specific column

Looking for a way to filter rows in a dataframe based on a sum condition of one of the columns. Specifically, I need the indexes of the first rows where the sum of column B is less than 3: df = pd.DataFrame({'A':[z, y, x, w], 'B':[1, 1, ...

Queries in Django's object-relational mapping (ORM)

Here are the tables I am currently working with: class ContestQuestions(models.Model): contest = models.ForeignKey(Contest, on_delete=models.CASCADE, related_name='contest_question_contest') quetions = models.Foreig ...

How come the ExpectedConditions invisibilityOfElementLocated method succeeds when using the element ID but fails when using the Classname for the preloader?

My current task involves waiting for the preloader to appear on a website. I have been utilizing ExpectedConditions.invisibilityOfElementLocated, but initially when I tried locating the preloader by its class name "DarkBg", the explicit wait did not wait f ...

Experimenting with Selenium to automate processes involving dynamic class attributes

My issue involves a Button class = "searchbar__SearchButton-sc-1546roh-3 searchbar__CancelButton-sc-1546roh-4 glEceZ" I am attempting to locate this element in the browser using return browser.element('button[class^="searchbar__CancelButton-"]&ap ...

Performing web scraping on a page rendered with Javascript in Python 3.5

I'm currently working on a project that involves extracting a dynamically rendered table using Python 3 and a webdriver. Below is the code I have implemented: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait fro ...

Making an HTTP request with binary data in Python via the Requests library

I am encountering an issue with my code that works in curl but not in Python using Requests. I am trying to understand why this discrepancy exists. curl 'http://cdcnepal.com/Modules/HOmeMoviesLists/WebService2.asmx/GetShowsByDate' \ -H &ap ...

Troubleshooting Pandas DataFrame Apply Operations

I am new to utilizing Pandas and have a particular inquiry that I'm hoping someone can assist me with. My goal is to apply a custom function called my_func to each row of a dataframe. res = df.apply(lambda x: my_func(x, par1, par2)) During debugging ...

Attempting to modify Namecheap's custom DNS field through Python Selenium

I am facing an issue while attempting to modify DNS settings for domains in Namecheap using Python Selenium Below is the HTML code: <select class="dashed-select add-margin ng-untouched ng-valid select2-offscreen ng-dirty ng-valid-parse" ng-change="nam ...

python color spyder plot legend

Using the provided dataset as a sample: df_toy = pd.DataFrame({"Group":[1,2], "Var1":[100,20], "Var2":[50,40], "Var3":[10,14], "Var4&qu ...

unable to choose an option from a dropdown menu using the select method in WebDriver

Here is a drop down code with different options to choose from: <select class="col-10 customDropdown focusOutVal xh-highlight" id="SourceOfIncome" name="PrimaryIncome.SourceOfIncome" sb="59436885" style="display: none;"><option value="" class="" ...

Unable to locate element by id in the search results on Amazon using Selenium

I have implemented the given python script: from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.firefox.options import Options from selenium.webdriver.support import ...

Is Selenium the Best Method for Scraping Websites and Extracting Table Data? How to effectively handle the output of a list DataFrame?

Looking for advice from a pandas expert. I'm currently navigating a webpage and opening tables by clicking on buttons to scrape data as read_html() is not working for me. Check out my code snippet; elem = sesh.find_element_by_xpath(f'{gen_butto ...

Failed to establish a connection with the host IP address 127.0.0.1 through port 7055 within a duration of 45000 milliseconds while utilizing Selenium

Browser: Firefox 50 version Selenium Jar files : 3.0.1 jar OS: Windows 7 enterprise 64 bit When running the scripts by selecting "Run as testNG suite" on the xml file, the browser opens but an error is immediately displayed in the console. I need guidanc ...

Selenium throwing a NoSuchElementException despite the presence of the element

I have encountered an issue with the following code snippet: driver.implicitly_wait(300) # I have experimented with different wait times driver.find_element_by_xpath("(//button[@aria-pressed='false'])[1]").click() Despite the fact that ...