Issue
using imports:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
I already changed to default and then to orderInfo Iframe :
driver.switch_to.default_content()
def changeIframetoOrders():
wait2 = WebDriverWait(driver, 10)
wait2.until(EC.frame_to_be_available_and_switch_to_it((By.NAME, "orderInfo")))
I tried by XPath
driver.find_element_by_css_selector("//html/body/div[1]/div/div/div[4]/div/div/div[2]/table"
"/tbody/tr/td/div/span[1]").text)
Im always following the rule to change to default iframe and then work on other iframe , still got sometime TimeOut ERROR or cant find element.
My entire code -UPDATED
# when i get to this DEF im in moduleManagment iframe
DATELIST = list()
wait5 = WebDriverWait(driver, 10)
# that click working in the module iframe
driver.find_element_by_xpath(
"//html/body/div[1]/div/div/div[3]/div[2]/div[1]/table/tbody/tr[" + str(rownumber) + "]/td[7]/div[1]/a").click()
# changing to orders iframe as i listed above
changeIframetoOrders()
# work on this
# print(driver.find_element_by_xpath("//div[contains(@class,'activitiy-log-msg')]/span").text)
# trying appending to a list the content of the span ...
DATELIST.append(driver.find_element_by_xpath("//div[contains(@class, 'activitiy-log-msg')]/span").text)
print(DATELIST)
# from here to the end im exit to the module iframe to click some Exit button.
driver.switch_to.default_content()
changeIframetoManagement()
wait5.until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, "div.modal-dialog button.bootbox-close-button"))).click()
return DATELIST
ERROR :
Traceback (most recent call last):
File ,
line 136, in <module>
changeIframetoOrders()
line 41, in changeIframetoOrders
wait2.until(EC.frame_to_be_available_and_switch_to_it((By.NAME,
"orderInfo")))
packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Solution
can you try with xpath
:
//div[contains(@class, 'activitiy-log-msg')]/span
code :
print(driver.find_element_by_xpath("//div[contains(@class, 'activity-log-msg')]/span").text)
Update 1 :
# when i get to this DEF im in moduleManagment iframe
DATELIST = list()
wait5 = WebDriverWait(driver, 10)
# that click working in the module iframe
driver.find_element_by_xpath(
"//html/body/div[1]/div/div/div[3]/div[2]/div[1]/table/tbody/tr[" + str(rownumber) + "]/td[7]/div[1]/a").click()
# changing to orders iframe as i listed above
driver.switch_to.default_content()
changeIframetoOrders()
# work on this
print(driver.find_element_by_xpath("//div[contains(@class, 'activitiy-log-msg')]/span").text)
# trying appending to a list the content of the span ...
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.