France conducted an underground nuclear weapons test today in the South Pacific just hours after Navy commandos seized an antinuclear protest ship of the environmental group Greenpeace a few miles from the test site.

Both the seizure of the vessel and the considerable publicity given to the test underlined France's determination to ignore protests in the region over its nuclear test policies.

Until now, French tests have been kept secret. Today's test, the first since the scandal over the sinking of a Greenpeace ship, was carried out in the presence of Prime Minister Laurent Fabius, Defense Minister Paul Quiles, a bipartisan parliamentary delegation and a dozen journalists who had been flown to the South Pacific for the occasion.

A communique from the Defense Ministry in Paris said that the test, code-named Hero after a figure in ancient Greek mythology, had "succeeded perfectly."

Although France has been testing nuclear weapons on its Pacific territory Mururoa Atoll since 1966, particular controversy surrounded this year's tests because of the sabotage of the Greenpeace ship Rainbow Warrior by the French secret services. The ship was blown up in the New Zealand port of Auckland July 10 to prevent it from leading a protest campaign against the tests.

Political analysts noted that the test of the French nuclear deterrent, the keystone of this country's independent defense policies, coincided with a summit of western leaders in New York. French President Francois Mitterrand refused an invitation from President Reagan to attend the meeting on the grounds that he was opposed to the formation of a western political "directorate."

In France, right-wing opposition leaders accused the Socialist government of exploiting the nuclear issue to win back popular support in advance of important legislative elections next March. There is a broad consensus here on the need to maintain and modernize the force de frappe, as the independent nuclear deterrent is called.

The inextricable link between foreign and domestic issues in an election year is illustrated by the fact that Fabius is due to appear in a television debate on Sunday shortly after his return from Mururoa. The debate, which will pit him against neo-Gaullist leader Jacques Chirac, is seen here as an opening shot in the future election campaign.

Speaking to journalists on Mururoa, about 12,000 miles and 14 hours' flying time from Paris, the prime minister said he was "in France."

"My visit is a sign of France's attachment to its nuclear deterrent. If you want a defense policy that is independent, it is necessary to have tests," he added.

Shortly before today's test, eight French military men boarded the Greenpeace yacht Vega after it entered a 12-mile French exclusion zone around Mururoa Atoll. The yacht was the only ship left in a protest flotilla that dispersed last week after its flagship, an ocean-going tug, developed engine trouble.

According to a Greenpeace spokesman in Tahiti, the four-person crew aboard the Vega was ordered below deck by the French officers after being instructed to stop by French Navy ships in the area. Defense Minister Quiles said the Greenpeace vessel was towed into international waters and the four persons aboard were arrested.

The French tests on Mururoa Atoll have been denounced by the leaders of eight South Pacific countries, including New Zealand and Australia, which signed a treaty earlier this year declaring the region a nuclear-free zone. Many Pacific islanders fear that the French tests will lead to radioactive pollution of the Pacific and its fish stocks.

Fabius denied yesterday that the French tests had a "poisonous effect" on the environment. He said France had taken "extraordinary precautions" to ensure the safety of the tests, which have been conducted underground since 1976.

The prime minister's visit to Mururoa was attacked by a leader of the neo-Gaullist party, Jacques Toubon, as a "political show" designed to shore up the Socialists' falling popularity.