vendredi 1 mai 2020

Selenium links request

I'm trying to download python.exe from the site using selenium. So I'm using that code:

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    driver = webdriver.Chrome("C:\\Program Files\\chromedriver.exe")
    driver.get("https://www.python.org/downloads/")
    try:
        c = WebDriverWait(driver,10).until(EC.presence_of_element_located(By.LINK_TEXT,"Download 
    Python 3.8.2"))
        c.click()
    finally:
        driver.quit()

But the shell always say:

   TypeError: __init__() takes 2 positional arguments but 3 were given

What is the issue? Thank you




PHP: How can I perform actions related to a particular session on my db once a user has closed the browser?

I am doing a food shopping website. I give a random number to any visitor on the site generated by rand() and when they add to cart, i give the cartNo that particular visitor No. However, if a visitor has added to cart and not proceeded to checkout, the items will remain in the cart and the next time they open the browser, they wont ever get that particular cartNo to which their items were added. I want to empty the cart in case that scenario happens. How do I do that?




Getting a notice for "Trying to access array of type bool" despite the same function working both above and below the troublesome query

So, I am trying to work on some PHP for classes, but am running into an issue with the above notice. The code is:

    <select name="RAM" id="RAM" style="grid-column: 2/ span 3; grid-row:8;">
        <?php foreach ($RAM as $row): ?>    
        <option><?=$row["name"]?></option>  
        <?php endforeach ?>
    </select>
    <label style="grid-column:5; grid-row:8">
        <?php showPrice($_POST["RAM"])?>
        </label>

    <select name="Storage" id="Storage" style="grid-column: 2/ span 3; grid-row:9;">
        <?php foreach ($STORAGE as $row): ?>    
        <option><?=$row["name"]?></option>  
        <?php endforeach ?>
    </select>
        <label style="grid-column:5; grid-row:9">
            <?php showPrice($_POST["Storage"])?>
        </label>

The errant section is the one labeled "RAM", which produces the error notice. I've tried echoing the $_POST to see if it gets the name of the selected item correctly. I've used the name within the SQL database to see if something was wrong with the names between the two.

But both of those do return the proper value I need, and the "Storage" section above does work as intended, so I can't quite tell what's causing it.




Cookies database to download

I want to build up a cookies database to do some statistics and play with it.

I am trying to find a dataset to download, or a way to build one, but I can't find any.

Is there any website where I can find this type of datasets?




Web google sign in not working on other's computer

I have written a javascript code that enables me to sign in with google on my PC but the same code does not work on other's computer. We are working on same project on firebase. How to resolve this issue?




Is higher number of different folders affecting website load speed?

I have one question about page load speed. Consider a case when I have different kinds of images on my web page, such as icons, logos, images inside content etc....

I want to know whether having separate folders for each media category may affect the page load speed:

/logos
/icons
/images

Will the webpage load faster if the images of all categories were located in a single folder rather in multiple ones?

Thanks in advance for your advice.




in a React App, JSON.Stringify shows only first ltem and a length item instead of other items

In a React App, I have an array that want to convert it to JSON and send it to the server. I do it with this:

console.log(JSON.stringify(mainArray"))

And I want to test it and I expect something like this to see:

"breakfast": {
                "1": "item 1",
                "2": "item 2"
            }

But I see only first item and a length item like this:

"breakfast": {
                "1": "item 1",
                "length": 2
            }

Also when I log the array without JSON.Stringify, I see something like this:

enter image description here

What's that proto ? Why I dont see my whole data in a clean way? Also in this situation, Every thing works fine if I do this:

console.lo(breakfast[0]) //prints first item
console.lo(breakfast[1]) //prints second item

First I thought its console.log's display problem, But when I send it to the server I get the same. I have just a simple array and I want to see it regularly.