I'm trying to select current date from the calendar on this website "www.makemytrip.com".
Using these 2 lines of code:
driver.findElement(By.xpath("//label[#for='departure']")).click();
To open the calendar and to select date:
driver.findElement(By.cssSelector(".DayPicker-Day.DayPicker-Day--selected.DayPicker-Day--today")).click();
The first one is working fine as it opens up the calendar but cssSelector is not responding. I've tried various variations but still it remains unresponsive.
Try this xpath strategy:
//div[#class='DayPicker-Day DayPicker-Day--today']
Now, i write in python, so you may translate my code to Java, since most of it remains same.
time.sleep (Thread.sleep in Java) here is optional Ideally you should use WebdriverWait instead of Thread.sleep. But just to show you, I used it.
driver.get('https://www.makemytrip.com/')
time.sleep(3)
driver.find_element(By.XPATH, "//label[#for='departure']").click()
time.sleep(1)
dx = driver.find_element(By.XPATH, "//div[#class='DayPicker-Day DayPicker-Day--today']")
print(dx.text)
dx.click()
Here is the output:
17 is the date and the other value is currency.
17
₹ 9,418
Process finished with exit code 0
Using FQL, by means of which finds events that contain a given word. FQL works only in API version <2.1. By which I use the Graph API Explorer to display events. Eg.
search?q=york&type=event
Example of FQL
SELECT Eid, name, location, start_time, description, pic_small, creator, event venue FROM WHERE start_time> "Sun Jun 21 0:00:35 GMT 2015" AND (CONTAINS ("york")
I would like to make a search events by using RestFB not using FQL, but do not know how. The documentation is scarce.
I answered this already on github, but perhaps someone else find this useful.
Your special case is not in the documentation, but you can transfer the knowledge you find in the documentation and solve your problem: http://restfb.com/#searching
Connection<Event> eventList =
facebookClient.fetchConnection("search", Event.class,
Parameter.with("q", "york"), Parameter.with("type", "event"));
Now, you can iterate over the eventList.
Here you can find how this can be done: http://restfb.com/#fetching-connections
I'm trying to change the date in a datepicker element using appium. I can't use the findElement(By.id("id"); since I'm running in version 4.2.2(API 17) and as far as i know By.id is not supported in this version. Using selendroid i can change the date like this:
driver.findElement(By.id("MONTH")).sendKeys("FEB");
In my code in appium I try to access it by the default date. For example im trying to change the month like this:
driver.findElement(By.name("Dec")).sendKeys("Jan");
It seems that although it finds the name Dec it can't send the keys Jan.
Here is the error from the Failure Trace:
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Any ides on how i can change it and generally if i can use somehow the findElement(By.id("id"); in this API version?
Thanks!!
Instead of using the By.name i used By.className in order to change the month the day and the year. Here is my code:
List<WebElement> date = driver.findElements(By.className("android.widget.NumberPicker"));
date.get(0).sendKeys("Apr");
date.get(1).sendKeys("17");
date.get(2).sendKeys("1972");
I'm trying to pull in specific data fields from the Bloomberg Java API. I see from the developers guide that I can pull in some fields with:
Request request = refDataSvc.createRequest("ReferenceDataRequest");
request.getElement("securities").appendValue("AAPL US Equity");
request.getElement("securities").appendValue("IBM US Equity");
request.getElement("fields").appendValue("PX_LAST"); // Last Price
request.getElement("fields").appendValue("DS002"); // Description
request.getElement("fields").appendValue("VWAP_VOLUME");
session.sendRequest(request, new CorrelationID(1));
How can I make a call like this while getting some of the fields over a specific date range? For example, I would like to get the: last trade price, last trade volume, the opening price for August 27th, 2012, and the VWAP volume for August 26th between 9AM and 11AM.
You need to create a "HistoricalDataRequest" request:
Request request = refDataSvc.createRequest("HistoricalDataRequest");
You can then specify the start date and end date:
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd");
request.set("startDate", startDate.toString(fmt));
request.set("endDate", endDate.toString(fmt));
In your case, startdate and enddate will be 27-Aug for the first request, and 26-Aug for the second.
However, I'm not sure how you can override fields (VWAP_START_TIME and VWAP_END_TIME) to restrict your VWAP to 9-11AM in a historical request, for reference data you would do smoething like the code below - it might work for historical requests too:
Element overridesElt = request.getElement("overrides");
Element override = overridesElt.appendElement();
override.setElement("fieldId", "VWAP_START_TIME");
override.setElement("value", "09:00:00");
override = overridesElt.appendElement();
override.setElement("fieldId", "VWAP_END_TIME");
override.setElement("value", "11:00:00");
I have a complex json written in a string. I know java and a little of mysql. I need to make a database out of the json.
I'm using some twitter data so the tweets contain the description of the user who tweeted it and in case it's been retweeted, it contains the description of the user who tweeted it before this user.
My objective is to create a user table ( or array or any other data structure ) which contains all the tweets this user tweeted, and all his tweets which have been retweeted.
The tweet object contains around 50-80 objects so giving an example here will make this post really long.
Example
StatusJSONImpl{createdAt=Wed Sep 28 12:04:55 IST 2011, id=118936707830775808, text='RT #nytimesbits: Google's Biggest Threat Is Google http://t.co/kTNqJFJC', source='web', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, inReplyToScreenName='null', geoLocation=null, place=null, retweetCount=6, wasRetweetedByMe=false, contributors=null, annotations=null, retweetedStatus=StatusJSONImpl{createdAt=Wed Sep 28 05:35:26 IST 2011, id=118838689248985088, text='Google's Biggest Threat Is Google http://t.co/kTNqJFJC', source='The New York Times', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, inReplyToScreenName='null', geoLocation=null, place=null, retweetCount=6, wasRetweetedByMe=false, contributors=null, annotations=null, retweetedStatus=null, userMentionEntities=[], urlEntities=[URLEntityJSONImpl{start=34, end=54, url=http://t.co/kTNqJFJC, expandedURL=http://nyti.ms/pR9DfX, displayURL=nyti.ms/pR9DfX}], hashtagEntities=[], user=UserJSONImpl{id=14434070, name='NYTimes Bits Blog', screenName='nytimesbits', location='The Cloud', description='News and analysis on tech and business. Also here: select retweets from NYT tech writers and friends. Account maintained by David F. Gallagher (#davidfg).', isContributorsEnabled=true, profileImageUrl='http://a1.twimg.com/profile_images/108833947/bits75_normal.jpg', profileImageUrlHttps='https://si0.twimg.com/profile_images/108833947/bits75_normal.jpg', url='http://nytimes.com/bits', isProtected=false, followersCount=53180, status=null, profileBackgroundColor='9ae4e8', profileTextColor='000000', profileLinkColor='0000ff', profileSidebarFillColor='e0ff92', profileSidebarBorderColor='87bc44', profileUseBackgroundImage=true, showAllInlineMedia=false, friendsCount=139, createdAt=Fri Apr 18 20:49:26 IST 2008, favouritesCount=5, utcOffset=-18000, timeZone='Eastern Time (US & Canada)', profileBackgroundImageUrl='http://a3.twimg.com/profile_background_images/4780380/twitter_post.png', profileBackgroundImageUrlHttps='https://si0.twimg.com/profile_background_images/4780380/twitter_post.png', profileBackgroundTiled=true, lang='en', statusesCount=6360, isGeoEnabled=false, isVerified=true, translator=false, listedCount=4671, isFollowRequestSent=false}}, userMentionEntities=[UserMentionEntityJSONImpl{start=3, end=15, name='NYTimes Bits Blog', screenName='nytimesbits', id=14434070}], urlEntities=[URLEntityJSONImpl{start=51, end=71, url=http://t.co/kTNqJFJC, expandedURL=http://nyti.ms/pR9DfX, displayURL=nyti.ms/pR9DfX}], hashtagEntities=[], user=UserJSONImpl{id=17989546, name='Wolfgang Fasching-K.', screenName='wwwof', location='Vienna', description='Digital ist besser. Fokus: IT & Internet, World News & US Politik, Medien & Pop/Kultur. http://www.riverone.at', isContributorsEnabled=false, profileImageUrl='http://a0.twimg.com/profile_images/67758989/SF050069-w_normal.JPG', profileImageUrlHttps='https://si0.twimg.com/profile_images/67758989/SF050069-w_normal.JPG', url='null', isProtected=false, followersCount=59, status=null, profileBackgroundColor='C0DEED', profileTextColor='333333', profileLinkColor='0084B4', profileSidebarFillColor='DDEEF6', profileSidebarBorderColor='C0DEED', profileUseBackgroundImage=true, showAllInlineMedia=false, friendsCount=64, createdAt=Tue Dec 09 17:09:35 IST 2008, favouritesCount=0, utcOffset=3600, timeZone='Vienna', profileBackgroundImageUrl='http://a3.twimg.com/profile_background_images/234523169/Naschmarkt-Wien-Juni10-2010-s.jpg', profileBackgroundImageUrlHttps='https://si0.twimg.com/profile_background_images/234523169/Naschmarkt-Wien-Juni10-2010-s.jpg', profileBackgroundTiled=true, lang='en', statusesCount=269, isGeoEnabled=false, isVerified=false, translator=false, listedCount=4, isFollowRequestSent=false}}
For JSON parsing, I recommend Jackson. Also, in order to validate your input, you should have a look at JSON Schema (for which I have an implementation if you want).
Here is how to parse a JSON in a string using Jackson:
final ObjectMapper mapper = new ObjectMapper();
final JsonNode node = mapper.readTree(yourInput);
// Access members:
node.get(0); // access node 0 of an array
for (final JsonNode entry: node) {
... // cycle through array nodes
}
node.get("foo"); // access property "foo" of an object
node.get("foo").getTextValue(); // access as a text
// etc etc
It also has a s*load of options to serialize to POJOs if that's what you want.
Your first step will be to parse the JSON to get an object graph, using a library like gson or any of several others.
Then (and this seems really general, but it's a pretty open question) it's a matter of determining what the schema should be, creating the tables, and looping through the object graph populating them.
You might look at "document databases" (so-called NoSQL) rather than SQL ones if you're allowed to, as they usually allow the schema to be more fluid.
If your problem is just with Twitter, you can look for dedicated APIs like Twiiter4J or Spring Social, that should provides ready java beans for tweets.
If you're realizing a small project Gson is the best solution for parsing. But if your making something more sophisticated, I suggest you to use Jackson for parsing and Hibernate as a middleware between application and sql database.