i want to locate count of elements which depends on the user account if the user has some stocks in the account then the element will appear other than that it will not so i have used css selector to locate the element because all the stock name has same css selector so it will give the list of elements and by list i can have the text of the elements and for that the code is given below.
### code
form = WebDriverWait(self.driver, 10).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.app')))
time.sleep(1)
print('oo')
z = self.driver.find_element(By.CSS_SELECTOR, 'a[href="/holdings"]')
z.click()
print('kk')
form = WebDriverWait(self.driver, 10).until(
EC.visibility_of_element_located((By.XPATH, "/html/body/div[1]")))
# time.sleep(1)
# form = WebDriverWait(self.driver, 10).until(
# EC.visibility_of_element_located((By.CSS_SELECTOR, "td[class='instrument right-border']")))
time.sleep(1)
count_of_stocks = self.driver.find_elements(By.CSS_SELECTOR, "td[class='instrument right-border']")
count = 0
print("no. of stocks")
print(len(count_of_stocks))
for i in count_of_stocks:
print(i.text)
### end
so this gives the output below:
### output
oo kk no. of stocks 10 APTUS DABUR DEVYANI FEDERALBNK GLS ITC JUBLFOOD MON100 TATACONSUM TATAMTRDVR
but when i try to run this same code in python_anyhwere it give the count wrong and not been able to locate the correct elements
and the output it give does not matches the output generate by the same code in local machine. Output generated by the python anywhere is given beloe:
####### output
oo kk no. of stocks 0
Questions : 1. Why does the output mismatch in python anywhere and local machine. 2. Why does the some elements work good in local machine but when the same element we run in python anywhere show the error that it is not able to locate the element.