Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- ChromeDriver driver = new ChromeDriver();
- String url = "https://www.czc.cz/macbooky/produkty";
- driver.get(url);
- List<WebElement> macs = null;
- try {
- macs = driver.findElementsByClassName("per-item medal tracked");
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- System.out.println(macs.size());
- WebElement firstMac = macs.get(0);
- String firstMacUrl = firstMac.getAttribute("href");
- System.out.println(firstMacUrl);
- driver.get(firstMacUrl);
- try {
- WebElement product = driver.findElementByPartialLinkText("Nokia 3310, Dual Sim, šedá");
- if (product.isDisplayed()) {
- System.out.println("Product is in the basket.");
- } else {
- System.out.println("Product not found in the basket");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement