I am a newbie in scrapy and just tried to crawl the hackernews. I am able to get the all the links and title from the site but the empty title and link are also getting crawled all along the data. How to avoid this or maybe i have done some error in declaring xpaths.
spider.py
from scrapy.spider import BaseSpider
from scrapy.selector import Selector
from hn.items import HnItem
class HNSpider(BaseSpider):
name = "hn"
allowed_domains = ["https://news.ycombinator.com/"]
start_urls = [
"https://news.ycombinator.com/"
]
def parse(self, response):
selector = Selector(response)
sites = selector.xpath('//td[#class="title"]')
items = []
for site in sites:
item = HnItem()
item['title'] = site.xpath('a/text()').extract()
item['link'] = site.xpath('a/#href').extract()
items.append(item)
for item in items:
yield item
output
2013-12-12 11:50:46+0530 [hn] DEBUG: Crawled (200) <GET https://news.ycombinator.com/> (referer: None)
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=11171475'],
'title': [u'Backpacker stripped of tech gear at Auckland Airport']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://sivers.org/ws'], 'title': [u'Why was this secret?']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.theatlantic.com/politics/archive/2013/12/how-americans-were-deceived-about-cell-phone-location-data/282239/'],
'title': [u'How Americans Were Deceived About Cell Phone Location Data']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.rockpapershotgun.com/2013/12/11/youtube-blocks-game-videos-industry-offers-help/'],
'title': [u'YouTube Blocks Game Videos, Industry Offers Help']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blog.fsck.com/2013/12/better-and-better-keyboards.html'],
'title': [u'Prototype ergonomic mechanical keyboards']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.timmins.net/2013/12/11/how-att-verizon-and-comcast-are-working-together-to-screw-you-by-discontinuing-landline-service/'],
'title': [u'How AT&T, Verizon, and Comcast are working together to screw you']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blog.samaltman.com/h5n1'], 'title': [u'H5N1']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.digitaltrends.com/gadgets/parents-dislike-infant-seat-ipad-mount/'],
'title': [u'Parents Revolt Over Fisher-Price Infant Seat With Face-Level iPad Mount ']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'https://www.fsf.org/news/reform-corporate-surveillance'],
'title': [u'Reform corporate surveillance']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://googledrive.blogspot.com/2013/12/newsheets.html?m=1'],
'title': [u'New Google Sheets: faster, more powerful, and works offline']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blogs.marketwatch.com/thetell/2013/12/11/fidelity-now-allows-clients-to-put-bitcoins-in-iras/'],
'title': [u'Fidelity now allows clients to put bitcoins in IRAs']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://bitmason.blogspot.ca/2013/09/what-are-containers-anyway.html'],
'title': [u'What are Linux containers and how did they come about?']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.cbc.ca/news/canada/ottawa/canada-post-to-phase-out-urban-home-mail-delivery-1.2459618'],
'title': [u'Canada Post to phase out urban home mail delivery']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.reuters.com/article/2013/12/11/fda-antibiotic-idUSL3N0JQ36T20131211'],
'title': [u'U.S. FDA to phase out some antibiotic use in animal production']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'https://lists.gnu.org/archive/html/guix-devel/2013-12/msg00061.html'],
'title': [u'GNU Guix 0.5 released']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'https://sites.google.com/site/ancientbharat/home'],
'title': [u'Ancient Indian Texts']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.creativebloq.com/responsive-design-tools-8134180'],
'title': [u'Responsive design tools']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.keacher.com/1216/how-i-introduced-a-27-year-old-computer-to-the-web/'],
'title': [u'How I introduced a 27-year-old computer to the web']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blog.sendtoinc.com/2013/12/11/silicon-valley-internship-j1-visa/'],
'title': [u'How to intern in Silicon Valley with a J1 visa']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'https://www.crowdtilt.com/campaigns/project-marilyn-part-i?utm_source=HackerNews&utm_medium=HNPost&utm_campaign=ProjectMarilyn'],
'title': [u'Project Marilyn Part I: Non-Patented Cancer Pharmaceutical']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://steamcommunity.com/groups/steamuniverse#announcements/detail/1930088300965516570'],
'title': [u'Steam Machines and Steam Controller shipping to beta participants December 13th']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blog.alexmaccaw.com/an-engineers-guide-to-stock-options'],
'title': [u'An Engineer\u2019s guide to Stock Options']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.vim3d.com/'],
'title': [u'Vim3D \u2013 A new 3D vi clone [video]']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://da-data.blogspot.com/2013/12/briefly-profitable-alt-coin-mining-on.html'],
'title': [u'Briefly profitable alt-coin mining on Amazon through better code']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://blog.jetbrains.com/idea/2013/12/intellij-idea-13-brings-a-full-bag-of-goodies-to-android-developers/'],
'title': [u'IntelliJ IDEA 13 Brings a Full Bag of Goodies to Android Developers']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://crowdmed.theresumator.com/apply/'],
'title': [u'CrowdMed (YC W13) is hiring a VP of Marketing + Web Dev and Design Interns']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://jh3y.github.io/tyto/'], 'title': [u'Show HN: tyto']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://www.washingtonpost.com/blogs/the-switch/wp/2013/12/10/nsa-uses-google-cookies-to-pinpoint-targets-for-hacking/'],
'title': [u'NSA uses Google cookies to pinpoint targets for hacking']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'https://access.redhat.com/site/products/Red_Hat_Enterprise_Linux/Get-Beta?intcmp=70160000000cINoAAM'],
'title': [u'Red Hat Enterprise Linux 7 Beta']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [], 'title': []}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'http://thenextweb.com/dd/2013/12/11/digia-releases-qt-5-2-android-ios-support-previews-windows-rt-launches-qt-mobile-edition/'],
'title': [u'Digia releases Qt 5.2 with Android and iOS support']}
2013-12-12 11:50:46+0530 [hn] DEBUG: Scraped from <200 https://news.ycombinator.com/>
{'link': [u'news2'], 'title': [u'More']}
2013-12-12 11:50:46+0530 [hn] INFO: Closing spider (finished)
You might have noticed from the output that title[] and link[] are getting repeated all the way along.
How to correct this. Please help.
There are few ways of doing that, i.e.:
By scrapy pipelines (http://doc.scrapy.org/en/latest/topics/item-pipeline.html):
You can add simple pipeline that will drop item if there is no title or link in it.
from scrapy.exceptions import DropItem
class DropEmptyPipeline(object):
def process_item(self, item, spider):
if "title" in item and "link" in item:
return item
else:
raise DropItem("Missing title or link in %s" % item)
By not adding item to items collection of it does not have title or link:
if "title" in item and "link" in item:
items.append(item)
Related
enter image description here
documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'prd-20-04-use1c10904074-d073-4f05-8205-cbd45384f44b', ip: '10.0.1.93', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-1015-gcp', java.version: '11.0.15'
Driver info: io.appium.java_client.AppiumDriver
Capabilities {app: /bitrise/deploy/reader-alph..., appActivity: com.nytimes.android.registe..., appPackage: com.nytimes.android, appWaitActivity: com.nytimes.android.registe..., appWaitDuration: 50000, appWaitForLaunch: true, appWaitPackage: com.nytimes.android, automationName: UiAutomator2, databaseEnabled: false, desired: {app: /bitrise/deploy/reader-alph..., appActivity: com.nytimes.android.registe..., appPackage: com.nytimes.android, appWaitActivity: com.nytimes.android.registe..., appWaitDuration: 50000, appWaitForLaunch: true, appWaitPackage: com.nytimes.android, automationName: UiAutomator2, deviceName: Android Emulator, platformName: Android, platformVersion: 10, resetKeyboard: false, unicodeKeyboard: false}, deviceApiLevel: 29, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenDensity: 420, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 2.625, platform: LINUX, platformName: LINUX, platformVersion: 10, resetKeyboard: false, statBarHeight: 63, takesScreenshot: true, unicodeKeyboard: false, viewportRect: {height: 1731, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: 6f253001-0fb1-437b-be63-710178cbb279
*** Element info: {Using=id, value=SettingsBarButton}
I am trying to create a choropleth with dropdown. I want to change colour scale with dropdown buttons, like min and max for each button. my recent scale is between 0 , 50 M. it makes sense for some buttons but for button A, it doesnt make any sense
thanks in advance
from urllib.request import urlopen import json with
urlopen("https://raw.githubusercontent.com/Babolius/project/62fef3b31fa9e34afb055e493de107d89a50a889/tr-cities-utf8.json")
as response:
id = json.load(response) import pandas as pd df = pd.read_csv("https://raw.githubusercontent.com/Babolius/project/main/komisyon5.csv",encoding
='utf8', dtype={"Toplam": int}) df.groupby(['ID']).sum()
import plotly.express as px
fig = px.choropleth_mapbox(df, geojson= id, locations= 'ID', color=
"Toplam",
color_continuous_scale="Viridis",
range_color=(0, 10000000),
mapbox_style="carto-darkmatter",
zoom=3, center = {"lat": 41.0902, "lon": 28.7129},
opacity=0.5,
)
dropdown_buttons =[{'label': 'A', 'method' : 'restyle', 'args': [{'z':
[df["A"]]}, {'visible': [True, False, False, False, False, False]},
{'title': 'A'}]},
{'label': 'B', 'method' : 'restyle', 'args': [{'z': [df["B"]]}, {'visible': [False, True, False, False, False, False]},
{'title': 'B'}]},
{'label': 'C', 'method' : 'restyle', 'args': [{'z': [df["C"]]}, {'visible': [False, False, True, False, False, False]},
{'title': 'C'}]},
{'label': 'D', 'method' : 'restyle', 'args': [{'z': [df["D"]]}, {'visible': [False, False, False, True, False, False]},
{'title': 'D'}]},
{'label': 'E', 'method' : 'restyle', 'args': [{'z': [df["E"]]}, {'visible': [False, False, False, False, True, False]},
{'title': 'E'}]},
{'label': 'Toplam', 'method' : 'restyle', 'args': [{'z': [df["Toplam"]]}, {'visible': [False, False, False, False,
False, True]}, {'title': 'Toplam'}]}]
fig.update_layout({'updatemenus':[{'type': 'dropdown', 'showactive':
True, 'active': 0, 'buttons': dropdown_buttons}]})
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}) fig.show()
It was easier than i thought
from urllib.request import urlopen
import json
with urlopen("https://raw.githubusercontent.com/Babolius/project/62fef3b31fa9e34afb055e493de107d89a50a889/tr-cities-utf8.json") as response:
id = json.load(response)
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/Babolius/project/main/komisyon5.csv",encoding ='utf8', dtype={"Toplam": int})
df.groupby(['ID']).sum()
import plotly.express as px
fig = px.choropleth_mapbox(df, geojson= id, locations= 'ID', color= "Toplam",
color_continuous_scale="Viridis",
color_discrete_sequence=(min, max),
mapbox_style="carto-darkmatter",
zoom=3, center = {"lat": 41.0902, "lon": 28.7129},
opacity=0.5,
)
dropdown_buttons =[{'label': 'A', 'method' : 'update', 'args': [{'z': [df["A"]]}, {'visible': [True, False, False, False, False, False]}, {'title': 'A'}]},
{'label': 'B', 'method' : 'update', 'args': [{'z': [df["B"]]}, {'visible': [False, True, False, False, False, False]}, {'title': 'B'}]},
{'label': 'C', 'method' : 'update', 'args': [{'z': [df["C"]]}, {'visible': [False, False, True, False, False, False]}, {'title': 'C'}]},
{'label': 'D', 'method' : 'update', 'args': [{'z': [df["D"]]}, {'visible': [False, False, False, True, False, False]}, {'title': 'D'}]},
{'label': 'E', 'method' : 'update', 'args': [{'z': [df["E"]]}, {'visible': [False, False, False, False, True, False]}, {'title': 'E'}]},
{'label': 'Toplam', 'method' : 'restyle', 'args': [{'z': [df["Toplam"]]}, {'visible': [False, False, False, False, False, True]}, {'title': 'Toplam'}]}]
fig.update_layout({'updatemenus':[{'type': 'dropdown', 'showactive': True, 'active': 0, 'buttons': dropdown_buttons}]})
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
When I run my wdio test I get the error:
Unable to create session from Desired Capabilities.
Any recommendation on this?
I have the selenium-server-standalone-3.141.59.jar running. Also I'm running the Appium
wdio version = v4.14.4
The entire Error:
ERROR: Unable to create session from {
"desiredCapabilities": {
"app": "\u002fhome\u002fAD\full_path.apk",
"rotatable": true,
"allowTestPackages": true,
"appiumVersion": "1.13.0",
"handlesAlerts": true,
"deviceName": "ANE-LX2J",
"requestOrigins": {
"url": "http:\u002f\u002fwebdriver.io",
"version": "4.14.4",
"name": "webdriverio"
},
"autoLaunch": true,
"platformVersion": "8.0.0",
"locationContextEnabled": true,
"name": "Test Breadwallet on android real devices",
"automationName": "UiAutomator2",
"browserName": "",
"javascriptEnabled": true,
"maxInstances": 1,
"platformName": "android"
},
"capabilities": {
"firstMatch": [
{
"browserName": "",
"platformName": "android"
}
]
}
}
More info:
Build info: version: 3.141.59
revision: e82be7d358
System info: host: jpdla00159.ad.sbibits.com
ip: 10.128.0.234
os.name: Linux, os.arch: amd64, os.version: 3.10.0-862.14.4.el7.x86_64,
java.version:1.8.0_19
Driver info: driver.version: unknown
Capabilities in wdio.conf.js:
capabilities: {
device: {
protocol: "http",
host: 'localhost',
port: 4444,
desiredCapabilities: {
name: "Android test on my app",
maxInstances: 1,
appiumVersion: "1.13.0",
platformName: "android",
platformVersion: "8.0.0",
automationName: "UiAutomator2",
browserName: "",
deviceName: "ANE-LX2J",
app: "/home/AD/xx/full_path.apk",
autoLaunch: true,
allowTestPackages: true
}
}
},
_
I'm trying to do an automated testing for a website using Nightwatch.js and I'm on macOS High Sierra.
So I started testing using the Selenium Standalone Server as said in the documentation.
The chrome testing works good and I have no problem with it. But I can't seem to make the Firefox testing work, I've been testing and searching online for a fix but I gave up because none of the solutions I found worked.
Here's is my nightwatch.json configuration file.
{
"src_folders": [
"test"
],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./bin/selenium-server-standalone-3.13.0.jar",
"log_path": "",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./bin/chromedriver",
"webdriver.gecko.driver": "./bin/geckodriver",
"webdriver.firefox.profile": "nightwatch"
}
},
"test_settings": {
"default": {
"launch_url": "https://www.google.com",
"selenium_port": 4444,
"selenium_host": "127.0.0.1",
"default_path_prefix": "",
"silent": true,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"marionette": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--load-extension=/Users/jackch/Downloads/chrome, --url-base=/wd/hub"
]
}
}
}
}
}
And then when I run nightwatch -e --verbose in the terminal, I get the same error Error retrieving a new session from the selenium server Connection refused! Is selenium server started?.
I tried many things:
1) I started geckodriver in a separate terminal on the default port 4444, and here are the logs from geckodriver:
2018-07-23 12:09:03.432 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7903, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.559 plugin-container[27769:6329668] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7943, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.624 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7b37, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:03.713 plugin-container[27770:6329696] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7bcf, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1532336943850 Marionette INFO Listening on port 52869
2018-07-23 12:09:04.333 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d07, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2018-07-23 12:09:04.413 plugin-container[27771:6329828] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7d83, name = 'com.apple.coredrag'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2) Then I tried to change the port of geckodriver, because I thought they may intefere since both Selenium and gecko choose the 4444 port, but nothing changed.
3) I tried to launch the Selenium server alone and then linking it. Which mean that I set the "start_process" to false in the nightwatch.json. And I still didn't manage to make it work.
Here is the complete message after I run nightwatch -e --verbose:
Starting selenium server... started - PID: 28112
[Test] Test Suite
=====================
Running: Login
INFO Request: POST /session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","marionette":true,"name":"Test"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":145}
INFO Response 200 POST /session (1721ms) { value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 } } } }
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ sessionId: '187e2af1-54a1-224a-9b8d-d4ff9f3913c7',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '61.0.1',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 28131,
'moz:profile': '/var/folders/vw/j4dsztz17sj_vtk500lv09r00000gn/T/rust_mozprofile.GRCHbtKdy2zm',
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'darwin',
platformVersion: '17.7.0',
rotatable: false,
timeouts: [Object] } } }
Thank you for any help you can bring.
I run nightwatch on mac os high sierra on firefox, safari, chrome. And on window opera, IE.
My config:
module.exports = {
"src_folders": ["tests"],
"output_folder": "reports",
// "live_output" : true,
// "parallel_process_delay" : 1500,
"custom_commands_path": "commands",
"custom_assertions_path": "assertions",
"page_objects_path": "",
"globals_path": "",
"selenium": {
"start_process": true,
"server_path": "./node_modules/nightwatch/lib/sel-serv.jar",
"log_path": "selenium_logs",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/.bin/chromedriver",
"webdriver.gecko.driver": "./node_modules/.bin/geckodriver",
"webdriver.edge.driver": "./node_modules/.bin/edgedriver",
"webdriver.ie.driver": "drivers/IEDriverServer.exe",
"webdriver.opera.driver": "drivers/operadriver.exe",
"webdriver.safari.driver": "/usr/bin/safaridriver"
}
},
"test_settings": {
"default": {
"selenium_port": 4444,
"selenium_host": "localhost",
"default_path_prefix": "/wd/hub",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "tmp_screenshots"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true,
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "firefox",
"user": "me1",
"pass": "test"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": [
"disable-web-security",
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "chrome",
"user": "me1",
"pass": "test"
}
},
"opera": {
"desiredCapabilities": {
"browserName": "opera",
"operaOptions": {
"binary": "C://Program Files//Opera//53.0.2907.68//opera.exe"
},
"acceptSslCerts": true,
"javascriptEnabled": true
},
"globals": {
"type": "opera",
"user": "me4",
"pass": "test"
}
},
"ie": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": 11,
"allowBlockedContent": true,
"javascriptEnabled": true,
"acceptSslCerts": true,
"ignoreProtectedModeSettings": true
},
"globals": {
"type": "ie",
"user": "me3",
"pass": "test"
}
},
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
},
"globals": {
"type": "safari",
"user": "me3",
"pass": "test"
}
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
}
};
I am attempting to run browser testing through the iOS simulator using webdriverIO. But instead of running the browser through the iOS simulator, it is just running it through the desktop version of Safari. I am not getting any errors. I am using the wdio test runner and this is in my config. Any suggestions?
capabilities: [
{
appiumVersion: '1.7.1',
deviceName: 'iPhone Simulator',
deviceOrientation: 'portrait',
platformversion: '9.0',
platformName: 'iOS',
port: '4723',
browserName: 'safari'
}
],
/
services: ['selenium-standalone', 'appium'],
appium: {
args: {
address: '127.0.0.1',
commandTimeout: '7200',
sessionOverride: true,
debugLogSpacing: true,
platformVersion: '9.0',
platformName: 'iOS',
showIosLog: true,
deviceName: 'iPhone',
nativeInstrumentsLib: true,
isolateSimDevice: true,
browserName: 'chrome'
}
},
I ended up getting this to work. I had set my config like so:
capabilities: [
{
maxInstances: 1,
browserName: 'safari',
appiumVersion: '1.7.1',
automationName: 'Appium',
deviceName: 'iPhone 7 Plus',
deviceOrientation: 'portrait',
platformVersion: '11.0',
platformName: 'iOS'
}
-
services: ['selenium-standalone', 'appium'],
appium: {
args: {
address: '127.0.0.1',
commandTimeout: '7200',
sessionOverride: true,
debugLogSpacing: true,
showIosLog: true,
nativeInstrumentsLib: true,
isolateSimDevice: true,
}
},
port: 4723,