2019-11-28

How to Stop Selenium browser popup "Failed to load extension from : c:/users/internal. Loading of unpacked extensions is disabled by the administrator".

How to Stop Selenium browser popup "Failed to load extension from : c:/users/internal. Loading of unpacked extensions is disabled by the administrator".



You can stop this by creating webdriver with special properties.

Example:

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.setExperimentalOption("useAutomationExtension", false);

How to handle browser admin login popup in selenium?

How to enter username and password to this browser login popup?



Solution:

You can send username and password in the URL request.

Example:  htpp://username:password@xyz.com


But in the latest web browser url credentials are blocked because of security issues.


Still you can use that features, you have to create web driver with some special operations.

Example:

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.addArguments("--disable-blink-features=BlockCredentialedSubresources");

This feature consider as network error.
You can reopen the URL.
Example:

driver.get("htpp://username:password@xyz.com");

driver.get("xyz.com");


2019-11-26

Java - Annotations for Concurrency

Class Annotations

We use three class-level annotations to describe a class's intended thread-
safety promises: @Immutable, @ThreadSafe, and @NotThreadSafe. @Immutable means, of
course, that the class is immutable, and implies @ThreadSafe. @NotThreadSafe is
optionalif a class is not annotated as thread-safe, it should be presumed not to
be thread-safe, but if you want to make it extra clear, use @NotThreadSafe.
These annotations are relatively unintrusive and are beneficial to both users
and maintainers. Users can see immediately whether a class is thread-safe,
and maintainers can see immediately whether thread-safety guarantees must
be preserved. Annotations are also useful to a third constituency: tools. Static
codeanalysis tools may be able to verify that the code complies with the
contract indicated by the annotation, such as verifying that a class annotated
with @Immutable actually is immutable.

Field and Method Annotations

The class-level annotations above are part of the public documentation for the
class. Other aspects of a class's thread-safety strategy are entirely for
maintainers and are not part of its public documentation.
Classes that use locking should document which state variables are guarded
with which locks, and which locks are used to guard those variables. A
common source of inadvertent non-thread-safety is when a thread-safe class
consistently uses locking to guard its state, but is later modified to add either
new state variables that are not adequately guarded by locking, or new
methods that do not use locking properly to guard the existing state variables.
Documenting which variables are guarded by which locks can help prevent
both types of omissions.
@GuardedBy(lock) documents that a field or method should be accessed only with
a specific lock held. The lock argument identifies the lock that should be held
when accessing the annotated field or method. The possible values for lock are:
@GuardedBy("this"), meaning the intrinsic lock on the containing object (the
object of which the method or field is a member);
@GuardedBy("fieldName"), meaning the lock associated with the object
referenced by the named field, either an intrinsic lock (for fields that do
not refer to a Lock) or an explicit Lock (for fields that refer to a Lock);
@GuardedBy("ClassName.fieldName"), like @GuardedBy("fieldName"), but referencing a
lock object held in a static field of another class;
@GuardedBy("methodName()"), meaning the lock object that is returned by calling
the named method;
@GuardedBy("ClassName.class"), meaning the class literal object for the named
class.
Using @GuardedBy to identify each state variable that needs locking and which
lock guards it can assist in maintenance and code reviews, and can help
automated analysis tools spot potential thread-safety errors.

Elasticsearch - Indices

Indices are containers for mapping types. An Elasticsearch index is an independent
chunk of documents, much like a database is in the relational world: each index is
stored on the disk in the same set of files; it stores all the fields from all the mapping
types in there, and it has its own settings. For example, each index has a setting called
refresh_interval, which defines the interval at which newly indexed documents are
made available for searches. This refresh operation is quite expensive in terms of per-
formance, and this is why it’s done occasionally—by default, every second—instead of
doing it after each indexed document. If you’ve read that Elasticsearch is near-real-time,
this refresh process is what it refers to.
TIP Just as you can search across types, you can search across indices. This
gives you flexibility in the way you can organize documents. For example, you
can put your get-together events and the blog posts about them in different
indices or in different types of the same index. Some ways are more efficient
than others, depending on your use case.
One example of index-specific settings is the number of shards. An index can be made up of one or more chunks called shards. This is good for
scalability: you can run Elasticsearch on multiple servers and have shards of the
same index live on all of them. Next, we’ll take a closer look at how sharding works
in Elasticsearch.

Elasticsearch - Types

Types are logical containers for documents, similar to how tables are containers for
rows. You’d put documents with different structures (schemas) in different types. For
example, you could have a type that defines get-together groups and another type for
the events when people gather.
 The definition of fields in each type is called a mapping. For example, name would
be mapped as a string, but the geolocation field under location would be mapped
as a special geo_point type. (We explore working with geospatial data in appendix A.)
Each kind of field is handled differently. For example, you search for a word in the
name field and you search for groups by location to find those that are located near
where you live.
TIP Whenever you search in a field that isn’t at the root of your JSON docu-
ment, you must specify its path. For example, the geolocation field under
location is referred to as location.geolocation.
You may ask yourself: if Elasticsearch is schema-free, why does each document belong
to a type, and each type contains a mapping, which is like a schema?
 We say schema-free because documents are not bound to the schema. They aren’t
required to contain all the fields defined in your mapping and may come up with
new fields. How does it work? First, the mapping contains all the fields of all the
documents indexed so far in that type. But not all documents have to have all fields.
Also, if a new document gets indexed with a field that’s not already in the mapping,
Elasticsearch automatically adds that new field to your mapping. To add that field, it
has to decide what type it is, so it guesses it. For example, if the value is 7, it assumes
it’s a long type.
 This autodetection of new fields has its downside because Elasticsearch might not
guess right. For example, after indexing 7, you might want to index hello world,
which will fail because it’s a string and not a long. In production, the safe way to go is
to define your mapping before indexing data.
 Mapping types only divide documents logically. Physically, documents from the
same index are written to disk regardless of the mapping type they belong to.

Elasticsearch - Documents

Elasticsearch is document-oriented, meaning the smallest unit
of data you index or search for is a document. A document has a few important prop-
erties in Elasticsearch:
■ It’s self-contained. A document contains both the fields (name) and their values
(Elasticsearch Denver).
■ It can be hierarchical. Think of this as documents within documents. A value of a
field can be simple, like the value of the location field can be a string. It can also
contain other fields and values. For example, the location field might contain
both a city and a street address within it.
■ It has a flexible structure. Your documents don’t depend on a predefined schema.
For example, not all events need description values, so that field can be omitted
altogether. But it might require new fields, such as the latitude and longitude of
the location.
A document is normally a JSON representation of your data. As we discussed in chap-
ter 1, JSON over HTTP is the most widely used way to communicate with Elasticsearch,
and it’s the method we use throughout the book. For example, an event in your get-
together site can be represented in the following document:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "location": "Denver, Colorado, USA"
}
NOTE Throughout the book, we’ll use different colors for the field names
and values of the JSON documents to make them easier to read. Field names
are darker/blue, and values are in lighter/red.
You can also imagine a table with three columns: name, organizer, and location. The
document would be a row containing the values. But there are some differences that
make this comparison inexact. One difference is that, unlike rows, documents can be
hierarchical. For example, the location can contain a name and a geolocation:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "location": {
 "name": "Denver, Colorado, USA",
 "geolocation": "39.7392, -104.9847"
 }
}


A single document can also contain arrays of values; for example:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "members": ["Lee", "Mike"]
}
Documents in Elasticsearch are said to be schema-free, in the sense that not all your doc-
uments need to have the same fields, so they’re not bound to the same schema. For
example, you could omit the location altogether in case the organizer needs to be
called before every gathering:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "members": ["Lee", "Mike"]
}
Although you can add or omit fields at will, the type of each field matters: some are
strings, some are integers, and so on. Because of that, Elasticsearch keeps a mapping
of all your fields and their types and other settings. This mapping is specific to every
type of every index. That’s why types are sometime called mapping types in Elastic-
search terminology.