当前位置: 首页>>代码示例>>Python>>正文


Python WebDriverWait.find_element_by_css_selector方法代码示例

本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.find_element_by_css_selector方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.find_element_by_css_selector方法的具体用法?Python WebDriverWait.find_element_by_css_selector怎么用?Python WebDriverWait.find_element_by_css_selector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.ui.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.find_element_by_css_selector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_tryon_item_from_dropdown

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
	def delete_tryon_item_from_dropdown(self):
		self.choose_tryon_items()
		tryon_item2_img = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.ID, "tryimgtmp42")), 'Timed Out')
		tryon_item2_img.click()
		dropdown = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.ID, "myDropdown42")), 'Timed Out')
		dropdown.find_element_by_css_selector("a:nth-child(1)").click()
		try:
			WebDriverWait(self.webdriver, 10).until(EC.invisibility_of_element_located((By.ID, "tryimgtmp42")), 'Timed Out')
			return True
		except TimeoutException:
			return False
开发者ID:judyyang40,项目名称:emFitting_automatedTesting,代码行数:13,代码来源:tryon_page.py

示例2: move_item_to_bottom_from_dropdown

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
	def move_item_to_bottom_from_dropdown(self):
		self.choose_tryon_items()
		tryon_item2_img = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.ID, "tryimgtmp42")), 'Timed Out')
		tryon_item2_img.click()
		dropdown = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.ID, "myDropdown42")), 'Timed Out')
		dropdown.find_element_by_css_selector("a:nth-child(3)").click()
		timeout = time.time()+5
		while True:
			if self.webdriver.find_element_by_css_selector("div.img_box > div:nth-child(2)").get_attribute("id") == "tryimgtmp42":
				return True
			elif time.time()>timeout:
				return False
开发者ID:judyyang40,项目名称:emFitting_automatedTesting,代码行数:14,代码来源:tryon_page.py

示例3: choose_place_without_one_region

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
 def choose_place_without_one_region(self):
     place_wrapper  =  WebDriverWait(self.driver, 30, 0.1).until(
         lambda d: d.find_element_by_css_selector(self.PLACE_WRAPPER)
     )
     place_rus = WebDriverWait(place_wrapper, 30, 0.1).until(
         lambda d: d.find_element_by_css_selector(self.PLACE_RUS)
     )
     place_rus.find_element_by_css_selector(self.PLACE_ICON).click()
     wrapper = place_rus.find_element_by_css_selector(self.AMUR)
     place_amur = WebDriverWait(wrapper, 30, 0.1).until(
         lambda d: d.find_element_by_css_selector(self.CHECKBOX)
     )
     if place_amur.is_selected():
         place_amur.click()
开发者ID:elviraux,项目名称:tech-testing-ha2,代码行数:16,代码来源:Component.py

示例4: check_for_blocking_popup

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
def check_for_blocking_popup(url):
	print("Check "+url+" for popup!")
	worked = 0
	try:
		driver = webdriver.Chrome()
		driver.get(url)
		element = WebDriverWait(driver, 10).until(
		    EC.presence_of_element_located((By.CSS_SELECTOR, "div#cboxClose"))
		)

		time.sleep(10)
		l = element.find_element_by_css_selector("div#cboxClose")
		l.click()
		element = WebDriverWait(driver, 15)
		articles = driver.find_elements_by_css_selector("td.gsc-table-cell-snippet-close")
		worked = 1
	except:
		traceback.print_exc(file=sys.stdout)
		try:
			traceback.print_exc(file=sys.stdout)
			time.sleep(10)
			l = driver.find_element_by_css_selector("div#cboxClose")
			l.click()
			element = WebDriverWait(driver, 15)
			articles = driver.find_elements_by_css_selector("td.gsc-table-cell-snippet-close")
			worked = 1
		except:	
			worked = 0
			traceback.print_exc(file=sys.stdout)
	
	if worked == 0:
		driver.quit()
		return [0,'']
	else:
		return [1,driver]
开发者ID:diegoolano,项目名称:whoyouelect,代码行数:37,代码来源:phantomscrape.py

示例5: test_add_report_for_remove_from_from_pending_the_ticket

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
def test_add_report_for_remove_from_from_pending_the_ticket(
        browser_o, pending_ticket):
    """
    :param browser_o:
    :type browser_o: tests.lives.MezzanineLiveBrowser
    :param pending_ticket:
    :type pending_ticket: helpdesk.models.Ticket
    """
    content = 'foo ' * 10
    action = 'remove_from_pending'
    browser_o.get(reverse(admin_urlname(Report._meta, 'add')) +
                  '?ticket={}'.format(pending_ticket.pk,))
    # insert the content of report
    browser_o.driver.find_element_by_id('id_content').send_keys(content)
    visible_from_req = browser_o.driver.find_element_by_id(
        'id_visible_from_requester')
    # select the checkbox for requester's visibility
    if not visible_from_req.is_selected():
        visible_from_req.click()
    # select the action 'remove_from_pending'
    browser_o.driver.find_element_by_css_selector(
        'input[value="{}"]'.format(action)).click()
    # select save button
    browser_o.driver.find_element_by_name('_save').click()
    browser_o.get(reverse(admin_urlname(Ticket._meta, 'change'),
                          args=(pending_ticket.id,)))
    tab_ticket_data = WebDriverWait(browser_o.driver, 10).until(
        ec.visibility_of_element_located((By.ID, 'tab_ticket_data')))
    status = tab_ticket_data.find_element_by_css_selector(
        ".table_ticket_data td.ticket_status")
    assert status.text.strip().lower() == 'open'
    # select tab of Messages
    browser_o.driver.find_element_by_css_selector(
        'a[href="#tab_messages"]').click()
    report = Report.objects.filter(ticket_id=pending_ticket.id).latest()
    message = browser_o.driver.find_element_by_id(
        'ticket_message_{}'.format(report.id))
    assert content in message.text
开发者ID:TicketHelpdesk,项目名称:TicketHelpdesk,代码行数:40,代码来源:test_operator_stories.py

示例6: fetch_csv

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
    def fetch_csv(self, auth, idstr, headers):
        # assemble url params
        if self.options['data'] == 'gen':
            tail = 'generation-mix'
            params = {'p_p_auth': auth,
                        'p_p_id': idstr,
                        'p_p_lifecycle': 2,
                        'p_p_state': 'normal',
                        'p_p_mode': 'view',
                        'p_p_resource_id': 'APP/1/GenMix.csv',
                        'p_p_cacheability': 'cacheLevelPage',
                        }

        url = self.base_url +tail #+'?'+'&'.join('%s=%s' % (k,v) for k,v in params.iteritems())

        fp = webdriver.FirefoxProfile()

        fp.set_preference("browser.download.folderList",2)
        fp.set_preference("browser.download.manager.showWhenStarting",False)
        fp.set_preference("browser.download.dir", os.getcwd())
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/msexcel")


        driver = webdriver.Firefox()
        driver.get(url)
        driver.refresh()
        try:
            div = WebDriverWait(driver, 20).until(
                    EC.presence_of_element_located((By.CLASS_NAME, "v-link"))
            )
            link = div.find_element_by_css_selector('a')
            link.click()
          #  print link.get_attribute('href')
            time.sleep(20)

        finally:
            driver.quit()
开发者ID:amills61,项目名称:pyiso,代码行数:39,代码来源:spp.py

示例7: goto_hand_tryon

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
	def goto_hand_tryon(self):
		hand = WebDriverWait(self.webdriver, 10).until(EC.visibility_of_element_located((By.ID, "index-tryon")), 'Timed Out')
		hand.find_element_by_css_selector(".row>.col-md-6:nth-child(2)").click()
		return self.base_url+'modules/index.php?pkg=tryon&contr=tryon&tryontype=hand' == self.webdriver.current_url
开发者ID:judyyang40,项目名称:emFitting_automatedTesting,代码行数:6,代码来源:index_page.py

示例8: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
            internalid = buttonid.split("$")[1]
            internalIDs.append(internalid)
            outdict[subject][internalid] = {}
            # these 'buttonids' are actually used for each subject thing
            # so will be very useful

    # Get course name
    for ident in internalIDs:
        coursetable = WebDriverWait(driver, timeout).until(
            EC.presence_of_element_located((By.ID, "win0divNYU_CLS_DERIVED_HTMLAREA$" + ident))
        )
        fulldesc = None
        try:
            desc = coursetable.find_element_by_class_name("courseDescription")
            courseid = desc.get_attribute("id").split("_")[1]  # to find the css id for long desc.
            coursetable.find_element_by_css_selector("a").click()
            longdesc = WebDriverWait(driver, timeout).until(
                EC.presence_of_element_located((By.ID, "fullDescription_" + courseid))
            )
            fulldesc = longdesc.text
        except selenium.common.exceptions.NoSuchElementException:
            fulldesc = coursetable.find_element_by_css_selector("p").text
        outdict[subject][ident]["desc"] = fulldesc
        outdict[subject][ident]["header"] = coursetable.find_element_by_css_selector("b").text

    # Get expanded table
    for ident in internalIDs:
        button = driver.find_element_by_id("NYU_CLS_DERIVED_TERM$" + ident)
        button.click()

        tableid = "ACE_NYU_CLS_DERIVED_TERM$" + ident
开发者ID:Skyyrunner,项目名称:JeevesCoursePlanner,代码行数:33,代码来源:albertscraper.py

示例9: processDOI

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]

#.........这里部分代码省略.........
        #go to full article page by adding URL prefix to DOI
        driver.get("http://pubs.acs.org/doi/full/" + DOI)

        #wait ten seconds and get title text to add to results object
        title = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CLASS_NAME, "hlFld-Title")))
        html_title = title.get_attribute('innerHTML').encode('utf-8')  

        # get authors
        authors = driver.find_elements_by_xpath(AUTHOR_XPATH)

        #join the text in the array of the correctly encoded authors
        authors_scrape = []
        for author in authors:
            authors_scrape.append(author.text)
           

        #deal with 2 and more authors formatting
        if ',' not in authors_scrape:
            authors_scrape = [x.replace('and', ' and ') for x in authors_scrape]
        else: 
            authors_scrape = [x.replace(',', ', ').replace(' and', 'and ') for x in authors_scrape]
        
        authorsjoined = (''.join(authors_scrape))

               
        #click figures link and form url, or set to empty string
        try:
            driver.find_element_by_class_name('showFiguresLink').click()
            
            #get toc image href
            img_box = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CLASS_NAME, "highRes")))
            if img_box is None:
                raise Exception
            toc_href = img_box.find_element_by_css_selector('a').get_attribute('href')
        except:
            toc_href = ''
            print 'no figures found'
        
         

        articleinfo = {
            "DOI": DOI,
            "Title": html_title,
            "article-link": article_link,
            "Authors": str(authorsjoined),
            "toc_href": str(toc_href),
            "Image": img_url,
            "Flask-image-path": img_path,
            "Coden": coden,
            "Datecode": datecode,
            "Clean_doi": cleanDOI

        }


        print "\n"  
        print articleinfo;
        print "\n"


        results.append(articleinfo)

    print results

    driver.close()
    driver.quit()
开发者ID:cornelius-k,项目名称:localflaskhighlights,代码行数:70,代码来源:highlightsnewtest.py

示例10: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
from bs4 import BeautifulSoup
import requests
import traceback
import sys
import time

try:
	driver = webdriver.Chrome()
	#driver = webdriver.PhantomJS()
	driver.get('http://www.texasobserver.org/search-results/?q=Abel+Herrero')
	element = WebDriverWait(driver, 10).until(
	    EC.presence_of_element_located((By.CSS_SELECTOR, "div#cboxClose"))
	)

	time.sleep(10)
	l = element.find_element_by_css_selector("div#cboxClose")
	l.click()
	element = WebDriverWait(driver, 15)
	articles = driver.find_elements_by_css_selector("td.gsc-table-cell-snippet-close")
except:
	traceback.print_exc(file=sys.stdout)
	time.sleep(10)
	l = driver.find_element_by_css_selector("div#cboxClose")
	l.click()
	element = WebDriverWait(driver, 15)
	articles = driver.find_elements_by_css_selector("td.gsc-table-cell-snippet-close")



links = []
for a in articles:
开发者ID:diegoolano,项目名称:whoyouelect,代码行数:33,代码来源:chrome.py

示例11: createVI

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]

#.........这里部分代码省略.........

        try:
            volume = soup.find("span", class_="citation_volume").text
            if volume is None:
                raise Exception
            else:
                volume = volume.encode("utf-8")
            
        except:
            volume = ''
            print 'volume not found'

        # Get issue info or set to empty string

        try:
            issue_info = soup.find("span", class_="citation_volume").next_sibling
            if issue_info is None:
                raise Exception
            issue_info = issue_info.encode("utf-8")
            
        except:
            issue_info = ''
            print 'issue not found'

        
        #click figures link and form url, or set to empty string
        try:
            driver.find_element_by_class_name('showFiguresLink').click()
            
            #get toc image href
            img_box = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CLASS_NAME, "highRes")))
            if img_box is None:
                raise Exception
            toc_href = img_box.find_element_by_css_selector('a').get_attribute('href')
        except:
            toc_href = ''
            print 'no figures found'

        
        
        articleinfo = {
            'DOI': DOI,
            'Title': html_title,
            'article-link': article_link,
            'Authors': str(authorsjoined),
            'toc_href': str(toc_href),
            'Image': img_url,
            # "full-citation": fullcitation
            'Journal': journal,
            'Volume': volume,
            'Issue-info': issue_info,
            'Year': year,
            "Datecode": datecode,
            "Clean_doi": cleanDOI
        }


        driver.close()
        driver.quit()
        print "\n"  
        print articleinfo;
        print "\n"


        results.append(articleinfo)
开发者ID:cornelius-k,项目名称:localflaskhighlights,代码行数:69,代码来源:virtualissueASAP.py

示例12: findTopCommentAndTopNumber

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]

#.........这里部分代码省略.........


    print("pre 9")

    try:
        WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.XPATH,"//a[@data-sort='popular']"))).click()
    except Exception as e:
        print "################### EXCEPTION a[@data-sort='popular']"
        self.driver.switch_to.default_content();
        return resultDict

    ##a data-role="username"
    print("pre 10")
    time.sleep(5)
    ##.updatable.count
    topCommentNumber = 0
    try:
        elm = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR,".updatable.count")))
        text = elm.text
        if isinstance(text, basestring) and len(text) > 0:
            try:
                topCommentNumber = int(text)
            except Exception as e:
                print "############# EXCEPTION fail to convert ot number"

    except Exception as e:
        print "#######################EXCEPTION Comment Number"

    if topCommentNumber < VOTEUP_CRITERIA:
        print "RETURNING Small Number"
        self.driver.switch_to.default_content();
        return resultDict



    


    ##.post-message


    """BROWSER UI: LOAD COMMENTS"""
   


    """Old page links should be gone"""


    topComment = ''

    print("pre 10")

    try:
        firstComment = WebDriverWait(self.driver, 5).until(EC.presence_of_element_located((By.CSS_SELECTOR,".post-message")))
        
        elms = firstComment.find_elements_by_css_selector('p')[0:2]
        for elm in elms[:]:
            if not elm.text:
                try:
                    _elm = elm.find_element_by_css_selector('i')
                except Exception as ee:
                    print("Exception: {0}".format(ee))
                if _elm.text:
                    topComment = topComment + ' ' + _elm.text
            else:
                topComment = topComment + ' ' + elm.text
            #print("topComment1: {0}".format(topComment))

    except Exception as e:
        print("Except: fail to find this element {0}".format(e))
        self.driver.switch_to.default_content();
        return resultDict

    #print("topComment2: {0}".format(topComment))
    topComment = re.sub(r'\\', "",topComment.strip())
    #print("topComment3: {0}".format(topComment))

    if len (topComment) < 10:
        print "top comment"
        self.driver.switch_to.default_content();
        return resultDict

    topComment = articleUtil.truncatedStringForRow(topComment);
    
    self.driver.switch_to.default_content();

    ##.photo>img
    ##<img height="458" width="570" itemprop="image" style="width: 100% !important;height:auto !important" src="//cdn.theatlantic.com/static/newsroom/img/mt/2015/02/HillaryBaby/lead.jpg?njdcj8"/>

    # if len(topComment) > WORDS_LIMIT:
    #     _topC = topComment[0:WORDS_LIMIT]
    #     tpC = re.sub(r'\.*$',"",_topC)
    #     topComment = "%s..." % tpC

    ##itemprop="datePublished"
    ##.content__dateline>time                

    #print "DONE Top Comment: %s TopCommentNumber: %s Timestamp: %s CommentNum: %s Title: %s" % (topComment, topCommentNumber, timeStamp, comNum, title)
    resultDict = {'topComment':topComment, 'topCommentNumber':topCommentNumber,'timeStamp': timeStamp, 'numComments': comNum, 'title': title}
    return resultDict
开发者ID:InfiniteRandomVariable,项目名称:hello-world,代码行数:104,代码来源:atlantic_comment.py

示例13: createVI

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]

#.........这里部分代码省略.........

        #Get citation year or set to nothing
        year = ''
        try:    
            
            YEAR_XPATH = "//*[@id=\"citation\"]/span[@class=\"citation_year\"]"
            yearscrape = driver.find_elements_by_xpath(YEAR_XPATH)

            for i in yearscrape:
                year = i.text.encode('utf-8')
        except:
            print 'year not found'
            continue

         

        #Get citation volume
        volume = ''
        try:
            
            VOLUME_XPATH = "//*[@id=\"citation\"]/span[@class=\"citation_volume\"]"
            volumescrape = driver.find_elements_by_xpath(VOLUME_XPATH)
            for i in volumescrape:
                volume = i.text.encode('utf-8')
        except:
            print 'volume not found'
            continue

        # Get issue info
        issue_info = ''
        citation = driver.find_element_by_id("citation")
        html = citation.get_attribute("outerHTML")

        soup = BeautifulSoup(html, "html.parser")

        try:
            issue_info = soup.find("span", class_="citation_volume").next_sibling
            issue_info = issue_info.encode("utf-8")
        except:
            print 'issue not found'
            continue

        # somewhere in here teh DOI gets messed up for 10.1021/acs.chemmater.5b01982. 
        print DOI
      
        #click figures link
        toc_href = ''
        try:
            
            driver.find_element_by_class_name('showFiguresLink').click()
        
            #get toc image href
            img_box = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CLASS_NAME, "highRes")))
            toc_href = img_box.find_element_by_css_selector('a').get_attribute('href')
        except:
            print 'TOC href not found'
            pass

        print DOI

      

        articleinfo = {
            "DOI": DOI,
            "Title": html_title,
            "article-link": article_link,
            "Authors": str(authorsjoined),
            "toc_href": str(toc_href),
            "Image": img_url,
            # "full-citation": fullcitation
            "Journal": journal,
            "Volume": volume,
            "Issue-info": issue_info,
            "Year": year,
        }

        driver.close()
        driver.quit()
        print "\n"  
        print articleinfo;
        print "\n"

        print myDOIs
        results.append(articleinfo)

    # print results

    keys = results[0].keys()

    with open('vi-csv.csv', 'wb') as f:
        dict_writer = csv.DictWriter(f, keys)
        dict_writer.writeheader()
        dict_writer.writerows(results)




        

    '''
开发者ID:cornelius-k,项目名称:localflaskhighlights,代码行数:104,代码来源:virtualissue-old.py

示例14: print

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
for book in books[:]:

	try:
		#print "6"
		print("find new book")
		browser.get(book.url)
		time.sleep(WAIT_SECONDS)

		print("find new book 1")
		reviewSectionElm = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.ID,"revMHRL")))
		if not reviewSectionElm:
			continue
		print("find new book 2")

		commentElm = reviewSectionElm.find_element_by_css_selector(".MHRHead")
		print("find new book 3")
		if not commentElm:
			continue

		print("find new book 4")
		comment = re.sub(r'\<br\/\>*', '', commentElm.text)

		if not comment or len(comment) < 2:
			print("Error comment {0}".format(comment))
			continue

		print("find new book 5")
		titleElm = reviewSectionElm.find_element_by_css_selector(".a-size-base.a-text-bold")
		if not titleElm:
			continue
开发者ID:InfiniteRandomVariable,项目名称:hello-world,代码行数:32,代码来源:amazonBooks.py

示例15: WebDriverWait

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_css_selector [as 别名]
				container = WebDriverWait(browser, 250).until(EC.presence_of_element_located((By.CSS_SELECTOR, REVIEW)))
				print("container1 ")
				htmlElm = container.get_attribute('innerHTML')
				#print("container1: {0}".format(htmlElm))
				article.topComment = container.text

			print 'article.topComment %s ' % article.topComment

		except Exception as eeee:
			print "Exception WSJ3.01 %s" % eeee

		if len(article.topComment) < 1 and container:
			try:
				print 'article.topComment 1 {0} {1}'.format(article.topComment, article.title)
				newReview = '{0}{1}'.format(REVIEW, 'p')
				elem  = container.find_element_by_css_selector('p')
				print 'article.topComment 1 {0} {1}'.format(article.topComment, article.title)
			except Exception as ee:
				print "Exception WSJ3.1 %s" % ee

			# if len(article.topComment) < 1:
			# 	try:
			# 		print 'article.topComment 2 %s ' % article.topComment
			# 		newReview = '{0}{1}'.format(newReview, '>p')
			# 		article.topComment = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, newReview))).text
			# 		print 'article.topComment 2 %s ' % article.topComment
			# 	except Exception as eee:
			# 		print "Exception WSJ3.2 %s" % eee

		##print('TopComment: {0}'.format(article.topComment))
开发者ID:InfiniteRandomVariable,项目名称:hello-world,代码行数:32,代码来源:wsj.py


注:本文中的selenium.webdriver.support.ui.WebDriverWait.find_element_by_css_selector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。