Tag type as string variable in selenium - css

How to pass tag type as a string variable in selenium?
suppose I am having given example:
By.cssSelector: li[__idx='0']
for given example I tried below part
webElement.findElement( By.cssSelector( "'" + tag + "'['" + property + "'='" + indexNumber + "']" ) )
where tag is li and __idx is property.
I am getting error as " Could not locate element with locator ". but if I tried as below then its working correctly.
webElement.getElement().findElement( By.cssSelector( "li[__idx='" + indexNumber + "']" ) )
Is there any syntactical mistake am doing ?

webElement.find( "" + tag + "[" + property + "='" + indexNumber + "']" );
This is the correct way to solve the issue.

Related

Getting image from an online XML file or a URL in xamarin forms

I am unable to get image from a URL that is an XML response. i used following code to fetch information from this URL including image too since i thought that i will get image although the xml response has image url but i am getting image URL instead of image.
Why is it so? kindly guide me! i am a newbie to xamarin forms.
URl : https://www.goodreads.com/book/title.xml?key=Uxb0zPb86N4STVy2ECWYA&title=Dune
CODE:
XElement search_result =(from xFi in Xdoc.Descendants("book")
where (xFi.Element("country_code").Value == "PK") || (xFi.Element("language_code").Value == "eng")
select xFi).FirstOrDefault();
if (search_result != null)
{ search.Text=
"Title: " + search_result.Element("title").Value + "\n" +
"Average Ratings: " + search_result.Element("average_rating").Value + "\n" +
"ISBN: " + search_result.Element("isbn").Value + "\n" +
"PUBLICATION YEAR: " + search_result.Element("publication_year").Value +
"\n" +"PUBLISHER: " + search_result.Element("publisher").Value + "\n" +
"DESCRIPTION: " + "\n" + search_result.Element("description").Value + "\n"
+ "IMAGE: " + "\n" + search_result.Element("image_url").Value + "\n";
} else
{
search.Text = "Found Nothing";
}
assuming I have an Image control on my page named "bookimage"
var url = search_result.Element("image_url").Value;
bookimage.Source = ImageSource.FromUri(new Uri(url));
this is clearly explained in the docs

JSoup - how does HTML structure affect response?

Trying to learn JSoup but having problems with response that may be due to structure issues (or stupidity, you tell me!). I do a simple query for "a[href]" but it only finds a subset 13 (text search tells me there are 162!). Why does it not find all?
Document doc = Jsoup.connect(J_URL).get();
String srchCSS = "a[href]";
Elements select = doc.select(srchCSS);
Iterator<Element> iterator = select.iterator();
Log.w(TAG, "'" + srchCSS + "' # " + select.size());
while (iterator.hasNext()) {
Element x = iterator.next();
System.out.println("'" + srchCSS + "': " + x.text());
}
Log.e(TAG, "%%% COMPLETE %%%");
I want to get the text from 'p' (see RED arrow). The a[href] above it is NOT being found?!?

html.partial with dynamic append using script (Razor)

trying to do the below
$('#body').append('<div id=\"'+ name + 'div\"' + '>' + '\'' + #Html.Partial("_ChatWindow") + '\'' + '</div>');
_chatwindow.cshtml is just
<button>test</button>
but i get a run time syntax error at the opening angle bracket of the partial class. Any suggestions?
You need to create a string for partial view content:
$('#body').append('<div id=\"'+ name + 'div\"' + '>' + '\'' + '#Html.Partial("_ChatWindow")' + '\'' + '</div>');

Inner query in fusion tables

This query will take input from three drop down box and a text box and it work's fine as expected.But my requirement is i need to use another three drop down box and a text in order to query much deeper.So,i need to hold the result of first query and also second query.How should i do.Help me.
That another three drop down box value is also obtained from the same variable's as 'operator','textvalue','querypass'.
function querymap()
{
var operator=document.getElementById('operatorstring').value.replace(/'/g, "\\'");
var textvalue=document.getElementById("text-value").value.replace(/'/g, "\\'");
var querypass=document.getElementById('query-pass').value.replace(/'/g, "\\'");
var searchStringe = document.getElementById('Search-stringe').value.replace(/'/g, "\\'");
var searchString = document.getElementById('search-string').value.replace(/'/g, "\\'");
{
layer.setQuery("SELECT 'geometry'," + querypass + " FROM " + tableid + " WHERE " + querypass + " " + operator + " '" + textvalue + "' AND VillageName = '"+ searchStringe+"'");
}
}
You can have as many AND conditions in your query as you want. No reason not to also check e.g. textvalue2, querypass2, searchString2, etc. and add them to your query. See this setQuery() answer which may give you some ideas. You'll need to set all your search conditions each time you call layer.setQuery() or layer.setOptions({query: ...});

The best browser detection solution in ASP.NET 4.0

I googled this topic and I came across with three different ways to configure browser capabilities: browscap.ini, browserCaps element in web.config and .browser files in App_Browsers. I thought .browser files is the latest way, but I don't seem to find up-to-date files. But I found quite fresh browscap.ini from http://browsers.garykeith.com/downloads.asp.
My first priority is to exclude common crawlers from the visitor stats. The second priority is to detect browser and os with correct versions (e.g. Opera 11 / Win7).
Are there any libraries I could use? Is browscap.ini still a valid way and is it possible to use it without access to system files? Where can I find up-to-date .browser files?
more info : http://msdn.microsoft.com/en-us/library/3yekbd5b.aspx
Have you checked this :
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n"
+ "Supports JavaScript Version = " +
browser["JavaScriptVersion"] + "\n";
TextBox1.Text = s;
I found a user agent parser from http://user-agent-string.info/ and it seems to be good enough for my purposes.
Just so no one else goes down that dark path, be aware that even the jQuery team recommend that you DO NOT use jQuery.browser object:
"The $.browser property is deprecated in jQuery 1.3"
The best answer is feature detection, not browser detection! This is particularly true in the day where Firefox & Chrome are putting out releases ever few months and mobile browser use is growing. Use Modernizr (http://Modernizr.com) or an equivalent library to detect the features you are interested in.
So far I've used http://api.jquery.com/jQuery.browser/ for client side detection.

Resources