[Solved] how can we add two String arraylist in hashmap and retrive value as match with key name index

I guess, you want to store first list items as keys and second list items as values in a HashMap. For that, you need to create a hashmap of string, string type as given below and store all its value there. HashMap<String, String> hmap = new HashMap<String, String>(); for(int i=0;i<a1.size();i++){ hmap.put(a1.get(i),a11.get(i)); } for(Map.Entry m:hmap.entrySet()) { … Read more

[Solved] Click a button using Selenium and Python

As per the HTML you can use the find_element_by_link_text and invoke click() method as follows : driver.find_element_by_link_text(“Expand all”).click() You can get more granualar with find_element_by_xpath as follows : driver.find_element_by_xpath(“//a[@class=”sectionname” and contains(.,’Expand all’)]”).click() Update As you still don’t see the expansion you can try the Javascript way as follows : myElement = driver.find_element_by_xpath(“//a[@class=”sectionname” and contains(.,’Expand all’)]”) … Read more

[Solved] How to locate an element and extract required text with Selenium and Python

You can use driver.find_element_by_css_selector(‘.form-control + [for=address]’).text Use replace() to remove the enter this code: string if required That is a class selector “.” with adjacent sibling combinator joining to attribute = value selector. So element with attribute for having value address that is adjacent to element with class form-control. solved How to locate an element … Read more

[Solved] How to scrape all product review from lazada in python

To do pagination use infinite while loop and #Check for button next-pagination-item have **disable** attribute then jump from loop else click on the next button. Code: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import time driver=webdriver.Chrome(executable_path=”chromedriver”) driver.get(“https://www.lazada.sg/products/loreal-paris-uv-perfect-even-complexion-sunscreen-spf50pa-30ml-i214861100-s325723972.html?spm=a2o42.seller.list.1.758953196tH2Mn&mp=1”) review_csv=[] product_csv = [] rating_csv =[] date_review_csv … Read more

[Solved] scraping with selenium web driver

You should fix your XPath expressions. Use findElement for the first 3. findElements for the last. To get the home odd : //td[a[.=”bet365″]]/following-sibling::td[span][1]/span To get the draw odd : //td[a[.=”bet365″]]/following-sibling::td[span][2]/span To get the away odd : //td[a[.=”bet365″]]/following-sibling::td[span][3]/span To get them all : //td[a[.=”bet365″]]/following-sibling::td[span]/span Getting them all is probably better since you call driver.find_elements_by_xpath 1 time. … Read more

[Solved] How to count total number of products on webpage and verify if those are correct with Selenium webdriver in Java? [closed]

The below java code will help you do the task Here we create a driver instance go to the website url take all the products into a list and compare it with the text “1-15 of 38 Matching Products” public static void main(String[] args) { WebDriver driver=new FirefoxDriver(); driver.get(“http://www.samsung.com/us/video/home-audio/all-products”); List products = driver.findElements(By.className(“product-image”)); String pagination_no[]=driver.findElement(By.xpath(“//*[@id=’category_filter’]/section/div[1]/div/div[1]/h1″)).getText().split(” … Read more

[Solved] SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘xpath’ is not a valid XPath expression [duplicate]

If you look at the XPath in the error message, you will probably see what the issue is. Your text isn’t surrounded by quotes as is required, e.g. td[@area-label=November 2025] should be td[@area-label=”November 2025″] To fix this, you need to adjust your line of code to dp_month = driver.find_element_by_xpath(‘//*/td[@aria-label=”‘+month_label+'”]/div[contains(text(),”‘+ x_month +'”)]’) solved SyntaxError: Failed to … Read more

[Solved] How to click FindNow button in selenium webdriver? [closed]

So, the way to click this button currently with the two options you have requested. It doesn’t look like you can use the id since it changes each time the page is loaded. But if you can catch the dynamically generated id it would like like so: WebElement we5 = null; we5 = driver.findElement(By.id(“queryButton_ns_0S7SWJ42MS972TW2Z74G_1576_”)); we5.cl‌​ick(); … Read more

[Solved] java code to find response time of a webpage without using selenium and apache

you can do it with HttpURLConnection connection = null; try { URL url = new URL(“http://stackoverflow.com/”); connection = (HttpURLConnection) url.openConnection(); long start = System.currentTimeMillis(); String jsonResponse = myInputStreamReader(connection.getInputStream()); long finish = System.currentTimeMillis(); long totalTime = finish – start; System.out.println(“Total Time for page load – ” + totalTime); } catch (Exception e) { e.printStackTrace(); } finally … Read more