element

How to retrieve elements from an array without slicing?

How to retrieve elements from an array without slicing? Question: Say I have an array, A1. B1 is another array storing the last two rows of A1. I need to retrieve the first two rows of A1 without slicing as another array (C1). Logically, I’m thinking something like A1 (the whole array) – B1 (the …

Total answers: 2

Checking the contents of the tuple in Python

Checking the contents of the tuple in Python Question: How would I be able to write a function that checks a tuple if it contains at least 2 H elements in the list. So for the example below there are 2 tuples in A that contain 2 H elements {(‘H’, ‘H’, ‘H’, ‘T’) and (‘T’, …

Total answers: 2

How can i get car names by using driver.find_elements(By.XPATH,'') with Python Selenium

How can i get car names by using driver.find_elements(By.XPATH,'') with Python Selenium Question: From this link, I want to get all of the car names as a list but only thing i can get is this: ————> Car name is : [] Here is the html code: <div class="headline-block u-margin-bottom-9"><span class="sponsored-badge">Sponsored</span><span class="h3 u-text-break-word">Opel Omega</span></div> Here …

Total answers: 2

How to obtain the number of elements with classname "xyz" through Selenium

How to obtain the number of elements with classname "xyz" through Selenium Question: Is it possible to do something like this? I want to know the number of elements with the class property set to ‘gsc-cursor-page’. pages_nav = driver.find_element_by_css_selector(‘.gsc-cursor’) pages = driver.find_element_by_css_selector(‘.gsc-cursor-page’) for pages in pages_nav: print("len(pages)") As shown below are (.gsc-cursor-page) inside (.gsc-cursor) So …

Total answers: 2

How to sort and filter a list in Python?

How to sort and filter a list in Python? Question: I have a list of list in Python that I want to sort based on two categories. The sorted list should have the lowest number in the last position and also the first element has to be greater than 400. I want to return the …

Total answers: 4

Python Selenium: Printing results as [<selenium.webdriver.remote.webelement.WebElement (session="9dc768d9ede71927c1403c99c6a8005b", element="cdb6a")>]

Python Selenium: Printing results as [<selenium.webdriver.remote.webelement.WebElement (session="9dc768d9ede71927c1403c99c6a8005b", element="cdb6a")>] Question: I have this line: from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from chromedriver_py import binary_path import config import pandas as pd from pretty_html_table import build_table from mailjet_rest import Client from apscheduler.schedulers.blocking import BlockingScheduler chrome_options = Options() chrome_options.add_argument("–headless") …

Total answers: 1

How to resolve TypeError: element_to_be_clickable() takes 1 positional argument?

How to resolve TypeError: element_to_be_clickable() takes 1 positional argument? Question: I’m getting the error TypeError: element_to_be_clickable() takes 1 positional argument but 2 were given when I run the following code: from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC url = ‘https://www.expedia.co.uk/’ …

Total answers: 2

How to find the index of the max value in a list for Python?

How to find the index of the max value in a list for Python? Question: I have a list, and I need to find the maximum element in the list and also record the index at which that max element is at. This is my code. list_c = [-14, 7, -9, 2] max_val = 0 …

Total answers: 6

how to sum elements among each other like arr[i] + arr[i+1] in python

how to sum elements among each other like arr[i] + arr[i+1] in python Question: I would like to create a function that sums first two elements and so on. Like: arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] result = [3, 5, 7, 9, 11, 13, 15, 17] I did something like …

Total answers: 1