There are numerous chemicals known to be carcinogenic. Exposure to these chemicals does not always lead to cancer formation but they do increase risk. The mode of contact (ingested orally versus applied to the skin) is often important, as well as the length of exposure. Common chemical carcinogens include tobacco smoke and benzenes. Laboratory studies on cells and animals are often used to categorize a substance as mutagenic, meaning that it leads to mutations in DNA. Substances determined to be mutagenic in those studies are likely carcinogenic in humans.
The most widely used test to determine if a chemical is mutagenic is the Ames test. The Ames test uses different strains of Salmonella bacteria growing in culture. Importantly these strains of Salmonella have been mutated such that they do not produce their own histidine which is required for their growth. A chemical being tested as a toxin or carcinogen is applied to the bacteria growing on a plate. After 48 hours incubation with limited amounts of histidine and in the presence of the chemical, colonies are counted. Only bacteria that mutated to produce histidine will continue to grow. The mutagenicity of the substance is determined by the number of colonies that were able to grow.
This test has limitations in determining the carcinogenicity of a substance in a human since humans have much more complex detoxification pathways and metabolism. These differences could make a compound less carcinogenic or they could make a substance more carcinogenic (if humans metabolize a substance into a carcinogen).